Compare commits
No commits in common. "develop" and "master" have entirely different histories.
124
.drone.yml
124
.drone.yml
@ -1,124 +0,0 @@
|
||||
---
|
||||
kind: pipeline
|
||||
name: build-linux
|
||||
|
||||
platform:
|
||||
arch: amd64
|
||||
|
||||
environment:
|
||||
SLEEP: 600
|
||||
|
||||
imagedefs:
|
||||
- &anchor_compiler_image
|
||||
image: dctl-registry.dcinet:5000/suse-15.4/gcc-113
|
||||
|
||||
steps:
|
||||
- name: build
|
||||
<<: *anchor_compiler_image
|
||||
volumes:
|
||||
- name: temp
|
||||
path: /tmp
|
||||
- name: cache
|
||||
path: /tmp/cache
|
||||
commands:
|
||||
- export CC=gcc
|
||||
- make -f makefile.shared test_standalone >test_gcc_1.txt 2>test_gcc_2.txt
|
||||
- ./test >test_std.txt 2>test_err.txt
|
||||
|
||||
|
||||
- name: build-fail
|
||||
<<: *anchor_compiler_image
|
||||
volumes:
|
||||
- name: temp
|
||||
path: /tmp
|
||||
- name: cache
|
||||
path: /tmp/cache
|
||||
commands:
|
||||
- echo "Go do some debugging - you've got $${SLEEP} seconds"
|
||||
- sleep $${SLEEP}
|
||||
- cat test_gcc_1.txt
|
||||
- cat test_std.txt
|
||||
- cat test_err.txt
|
||||
when:
|
||||
status:
|
||||
- failure
|
||||
|
||||
- name: build-success
|
||||
<<: *anchor_compiler_image
|
||||
volumes:
|
||||
- name: temp
|
||||
path: /tmp
|
||||
- name: cache
|
||||
path: /tmp/cache
|
||||
commands:
|
||||
# - echo "Go check where the binaries are - you've got $${SLEEP} seconds"
|
||||
# - sleep $${SLEEP}
|
||||
- cat test_gcc_2.txt
|
||||
depends_on:
|
||||
- build
|
||||
when:
|
||||
status:
|
||||
- success
|
||||
|
||||
# ### NOTE build-install is of no use to us for fireswarm as it only installs the static library and header
|
||||
# ### It is easier to pull shared lib from .libs/libtfm.so.1.0.0 and header from src/headers/tfm.h
|
||||
#- name: build-install
|
||||
#<<: *anchor_compiler_image
|
||||
#volumes:
|
||||
#- name: temp
|
||||
#path: /tmp
|
||||
#- name: cache
|
||||
#path: /tmp/cache
|
||||
#commands:
|
||||
#- make install
|
||||
#- ls -R -l /usr/local/* | grep tfm
|
||||
#depends_on:
|
||||
#- build-success
|
||||
|
||||
|
||||
# ### TODO package up the contents of .libs and maybe the public header?
|
||||
# #-rw-r--r-- 1 root root 325206 May 13 09:06 libtfm.a
|
||||
# #lrwxrwxrwx 1 root root 12 May 13 09:06 libtfm.la -> ../libtfm.la
|
||||
# #-rw-r--r-- 1 root root 909 May 13 09:06 libtfm.lai
|
||||
# #lrwxrwxrwx 1 root root 15 May 13 09:06 libtfm.so -> libtfm.so.1.0.0
|
||||
# #lrwxrwxrwx 1 root root 15 May 13 09:06 libtfm.so.1 -> libtfm.so.1.0.0
|
||||
# #-rwxr-xr-x 1 root root 233136 May 13 09:06 libtfm.so.1.0.0
|
||||
# #-rw-r--r-- 1 root root 671 May 13 09:06 libtfm.ver
|
||||
|
||||
volumes:
|
||||
- name: cache
|
||||
host:
|
||||
path: /srv/dockerctl_icc/cache
|
||||
- name: staging-icc
|
||||
host:
|
||||
path: /srv/dockerctl_icc/staging
|
||||
- name: temp
|
||||
temp: {}
|
||||
|
||||
|
||||
trigger:
|
||||
# For now we only run on demand
|
||||
event:
|
||||
- custom
|
||||
# Disable running pipeline a second time when we promote a successful build
|
||||
exclude:
|
||||
- promote
|
||||
|
||||
|
||||
# ---
|
||||
# kind: pipeline
|
||||
# name: build-windows
|
||||
|
||||
# platform:
|
||||
# arch: amd64
|
||||
|
||||
# environment:
|
||||
# MYCC: gcc" SHARED="-f makefile.shared"
|
||||
|
||||
# steps:
|
||||
# - name: test
|
||||
# image: gcc
|
||||
# commands:
|
||||
# - ${MYCC}" make ${SHARED} test_standalone >test_gcc_1.txt 2>test_gcc_2.txt && ./test >test_std.txt 2>test_err.txt"
|
||||
|
||||
...
|
4
.gitattributes
vendored
4
.gitattributes
vendored
@ -1,4 +0,0 @@
|
||||
/.gitattributes export-ignore
|
||||
/.gitignore export-ignore
|
||||
|
||||
/** export-subst
|
15
.gitignore
vendored
15
.gitignore
vendored
@ -14,15 +14,6 @@
|
||||
.cproject
|
||||
/.libs
|
||||
test_*.txt
|
||||
*.pc
|
||||
doc/tfm.pdf
|
||||
pre_gen/
|
||||
|
||||
*.gcda
|
||||
*.gcno
|
||||
*.info
|
||||
coverage/
|
||||
compat_reports/
|
||||
|
||||
test
|
||||
test.exe
|
||||
@ -34,9 +25,3 @@ rsatest
|
||||
rsatest.exe
|
||||
timing
|
||||
timing.exe
|
||||
/Build/
|
||||
/cmake/sources.txt
|
||||
/.drone.yml.lint.txt
|
||||
/yamllint-config.yml
|
||||
/yamllint.sh
|
||||
/yq.sh
|
||||
|
17
.kateconfig
17
.kateconfig
@ -1,17 +0,0 @@
|
||||
# global editor options
|
||||
auto-brackets false;
|
||||
indent-width 4;
|
||||
newline-at-eof on;
|
||||
replace-tabs on;
|
||||
replace-tabs-save on;
|
||||
tab-width 4;
|
||||
|
||||
# Force override of cmake options
|
||||
|
||||
kate-wildcard(*.cmake;CMakeLists.txt): auto-brackets false;
|
||||
kate-wildcard(*.cmake;CMakeLists.txt): indent-width 4;
|
||||
kate-wildcard(*.cmake;CMakeLists.txt): newline-at-eof on;
|
||||
kate-wildcard(*.cmake;CMakeLists.txt): replace-tabs on;
|
||||
kate-wildcard(*.cmake;CMakeLists.txt): replace-tabs-save on;
|
||||
kate-wildcard(*.cmake;CMakeLists.txt): tab-width 4;
|
||||
|
@ -1,5 +0,0 @@
|
||||
{
|
||||
"name": "CMakeLists",
|
||||
"directory": "/srv/code/cpp/FireSwarm",
|
||||
"files": [ { "git": 1 } ]
|
||||
}
|
@ -1,14 +1,6 @@
|
||||
dist: trusty
|
||||
sudo: required
|
||||
language: c
|
||||
compiler:
|
||||
- gcc
|
||||
branches:
|
||||
only:
|
||||
- master
|
||||
- develop
|
||||
- /^release/
|
||||
- /^travis/
|
||||
script: CC="${MYCC}" make ${SHARED} test_standalone >test_gcc_1.txt 2>test_gcc_2.txt && ./test >test_std.txt 2>test_err.txt
|
||||
env:
|
||||
- MYCC="gcc" SHARED=""
|
||||
|
464
CMake.sh
464
CMake.sh
@ -1,464 +0,0 @@
|
||||
#!/bin/bash
|
||||
|
||||
todo() {
|
||||
<< TODO
|
||||
|
||||
- Continue with adding platform(s)
|
||||
- Add support for other platforms such as x86.
|
||||
- Add support for Release | Debug | DebugInfo etc.
|
||||
- If generating CodeBlocks support...
|
||||
- Parse the source and for each CMakeLists found add it to the workspace
|
||||
|
||||
TODO
|
||||
}
|
||||
|
||||
load_opts() {
|
||||
|
||||
GETOPT=$( getopt -o bcdDfhiru \
|
||||
--long build,cmakehelp,debug,dry-run,fbver:,fresh,help,info,reset,usecodeblocks,verbose \
|
||||
-n "$0" -- "$@" )
|
||||
}
|
||||
|
||||
ShowHelp(){
|
||||
tabs 3,5,9,13,17,21,25,29,33,37,41,45,49,53,57,61,65,69,73,77
|
||||
DOCNOTE=$(cat << MSG > ${BASENAME}-readme.md
|
||||
|
||||
# CMake wrapper script
|
||||
|
||||
This script encapsulates the necessary calls to the CMake binary to configure
|
||||
and generate the makefiles required to build this application.
|
||||
|
||||
Optionally a full build can also be executed.
|
||||
|
||||
|
||||
### Options
|
||||
|
||||
- (boolean) help
|
||||
Outputs this help screen and quits.
|
||||
|
||||
- (boolean) build
|
||||
Will execute make in the build dir if makefile generation was successful.
|
||||
|
||||
- (boolean) cmakehelp
|
||||
Outputs the CMake help screen and quits.
|
||||
|
||||
- (string) --fbver
|
||||
The firebird version to build against.
|
||||
This must be in the format 'fb4', 'fb5' etc.
|
||||
The script will exit if this parameter is not supplied.
|
||||
|
||||
NOTE: Currently this application does not need to know the firebird version.
|
||||
This setting is just a formality. However, firebird __MUST__ be installed.
|
||||
|
||||
- (boolean) --fresh
|
||||
Pass --fresh to cmake, removing existing cache files.
|
||||
|
||||
- (boolean) --reset
|
||||
Delete the Build dir. Recommended if thinks start to go wrong after
|
||||
successive runs of CMake but should not usually be required.
|
||||
|
||||
- (boolean) --usecodeblocks
|
||||
Generates CodeBlocks project files in addition to standard make files
|
||||
These will be placed under the Build dir.
|
||||
(Not tested.)
|
||||
|
||||
|
||||
### Examples
|
||||
|
||||
- Configure and Generate make files for all platforms
|
||||
|
||||
CMake.sh --fbver fb4
|
||||
|
||||
- Check the CMake Help screen
|
||||
|
||||
CMake.sh --cmakehelp
|
||||
|
||||
- Configure, Generate and build all platforms
|
||||
|
||||
CMake.sh --fbver fb4 -build
|
||||
|
||||
|
||||
MSG
|
||||
)
|
||||
|
||||
cat ${BASENAME}-readme.md
|
||||
}
|
||||
|
||||
|
||||
######################### START OF GENERIC FUNCTIONS #########################
|
||||
|
||||
Pause(){
|
||||
|
||||
local _aprompt=""
|
||||
|
||||
if [ "${1:-}" = "" ]; then
|
||||
_aprompt="Press any key to continue..."
|
||||
else
|
||||
_aprompt="$*"
|
||||
fi
|
||||
|
||||
#shellcheck disable=SC2162
|
||||
read -p "$_aprompt"
|
||||
|
||||
}
|
||||
|
||||
|
||||
GetTime(){
|
||||
|
||||
export LOGSTAMP=$(date "+%Y-%m-%d %H:%M:%S")
|
||||
export DATESTAMP=$(date +%Y%m%d)
|
||||
export TIMESTAMP=$(date +%Y%m%d-%H%M%S)
|
||||
export TAGSTAMP=$(date +:%Y%m%d%H%M)
|
||||
|
||||
case "${1:-}" in
|
||||
LOGSTAMP)
|
||||
echo LOGSTAMP is "$LOGSTAMP"
|
||||
;;
|
||||
DATESTAMP)
|
||||
echo DATE is "$DATESTAMP"
|
||||
;;
|
||||
TIMESTAMP)
|
||||
echo TIMESTAMP is "$TIMESTAMP"
|
||||
;;
|
||||
TAGSTAMP)
|
||||
echo TAGSTAMP is "$TAGSTAMP"
|
||||
;;
|
||||
esac
|
||||
|
||||
}
|
||||
|
||||
|
||||
GetLogStamp() {
|
||||
GetTime "LOGSTAMP"
|
||||
}
|
||||
|
||||
|
||||
Debug() {
|
||||
|
||||
# Debug is intended for printing values assigned to variables etc.
|
||||
if [ "${DEBUG:-}" == "1" ]; then
|
||||
GetTime
|
||||
local FUNC=$1
|
||||
shift
|
||||
echo -e $LOGSTAMP $FUNC "-" "$@"
|
||||
fi
|
||||
|
||||
}
|
||||
|
||||
|
||||
Verbose() {
|
||||
|
||||
# Verbose is intended to give the user a more
|
||||
# detailed narrative of programm execution.
|
||||
# shellcheck disable=SC2166
|
||||
if [ "${VERBOSE:-}" == "1" -o "${DEBUG:-}" == "1" ]; then
|
||||
GetTime
|
||||
if [ "${2:-}" = "" ]; then
|
||||
echo -e $LOGSTAMP "$@"
|
||||
else
|
||||
local FUNC=${1:-}
|
||||
shift
|
||||
echo -e $LOGSTAMP $FUNC "-" "$@"
|
||||
fi
|
||||
fi
|
||||
|
||||
}
|
||||
|
||||
|
||||
EchoSpacer() {
|
||||
set +x
|
||||
|
||||
# Echo a divider line to output
|
||||
|
||||
if [ -z ${1:-} ]; then
|
||||
_spacer="-"
|
||||
else
|
||||
_spacer=$1
|
||||
fi
|
||||
|
||||
if [ -z ${2:-} ]; then
|
||||
_repeat="80"
|
||||
else
|
||||
_repeat=$2
|
||||
fi
|
||||
|
||||
echo -e "\n"
|
||||
for a in $(seq 1 ${_repeat} )
|
||||
do
|
||||
echo -n "$_spacer"
|
||||
done
|
||||
echo -e "\n"
|
||||
|
||||
}
|
||||
|
||||
|
||||
WriteLog() {
|
||||
|
||||
# Param 1 - Logfile
|
||||
# Param 2 - FUNCNAME
|
||||
# We automatically call Verbose after shifting LOGFILE
|
||||
# We then shift FUNCNAME and write out to the log.
|
||||
GetTime
|
||||
local LOGFILE=${1:-}
|
||||
shift
|
||||
Verbose "$@"
|
||||
# shellcheck disable=SC2166
|
||||
if [ ! "${VERBOSE:-}" = 1 -o ! "${DEBUG:-}" = 1 ]; then
|
||||
shift
|
||||
fi
|
||||
if [ ! "${LOGFILE:-}" = "" ]; then
|
||||
echo -e $LOGSTAMP "-" "$@" >> $LOGFILE
|
||||
fi
|
||||
|
||||
}
|
||||
|
||||
|
||||
Stop() {
|
||||
|
||||
# echo an error code and a message and stop execution.
|
||||
local _err=0
|
||||
if [ "${1:-}" -ge 0 ] 2>/dev/null ; then
|
||||
_err=$1
|
||||
shift
|
||||
fi
|
||||
|
||||
echo "$@"
|
||||
exit $_err
|
||||
|
||||
}
|
||||
|
||||
|
||||
Error(){
|
||||
|
||||
local _err=0
|
||||
if [ "${1:-}" -ge 0 ] 2>/dev/null ; then
|
||||
_err=$1
|
||||
shift
|
||||
fi
|
||||
|
||||
EchoSpacer
|
||||
echo ""
|
||||
echo " Error in $0"
|
||||
echo " $* "
|
||||
echo ""
|
||||
EchoSpacer
|
||||
return $_err
|
||||
|
||||
<< COMMENT
|
||||
Use Error on its own thus:
|
||||
|
||||
Error 1 A remark about the error
|
||||
|
||||
In this case it is up to the caller to test the error code
|
||||
|
||||
Or use it with Stop:
|
||||
|
||||
Error 1 A remark about the error
|
||||
Stop $?
|
||||
|
||||
COMMENT
|
||||
|
||||
}
|
||||
|
||||
|
||||
######################### END OF GENERIC FUNCTIONS #########################
|
||||
|
||||
ResetVars() {
|
||||
|
||||
unset BUILD
|
||||
unset CMAKEHELP
|
||||
unset DEBUG
|
||||
unset DRYRUN
|
||||
unset FRESH
|
||||
unset FBVER
|
||||
unset RESET
|
||||
unset SHOWINFO
|
||||
unset USECODEBLOCKS
|
||||
|
||||
BASENAME=$(basename "$0" .sh)
|
||||
GENERATOR="Unix Makefiles"
|
||||
SCRIPTPATH="$( cd -- "$(dirname "$0")" >/dev/null 2>&1 ; pwd -P )"
|
||||
|
||||
}
|
||||
|
||||
|
||||
ParseCommandLine() {
|
||||
#set -x
|
||||
if [ $# -le 0 ]; then
|
||||
ShowHelp
|
||||
return 1
|
||||
fi
|
||||
eval set -- "$GETOPT"
|
||||
|
||||
while true; do
|
||||
case "${1:-}" in
|
||||
|
||||
-h|--help) return 1 ;;
|
||||
|
||||
-b|--build)
|
||||
BUILD=" --build ";
|
||||
shift;
|
||||
;;
|
||||
|
||||
-c|--cmakehelp)
|
||||
CMAKEHELP=" --help ";
|
||||
shift;
|
||||
;;
|
||||
|
||||
-d|--debug)
|
||||
DEBUG=1;
|
||||
shift;
|
||||
;;
|
||||
|
||||
-D|--dry-run)
|
||||
DRYRUN=1;
|
||||
shift;
|
||||
;;
|
||||
|
||||
-f|--fresh)
|
||||
FRESH=" --fresh ";
|
||||
shift;
|
||||
;;
|
||||
|
||||
--fbver)
|
||||
if [ "$2" ] > /dev/null 2>&1; then
|
||||
FBVER="$2";
|
||||
fi
|
||||
shift; shift;
|
||||
;;
|
||||
|
||||
-i|--info)
|
||||
SHOWINFO=1;
|
||||
shift;
|
||||
;;
|
||||
|
||||
-r|--reset)
|
||||
RESET=1;
|
||||
shift;
|
||||
;;
|
||||
|
||||
-u|--usecodeblocks)
|
||||
GENERATOR="CodeBlocks - Unix Makefiles";
|
||||
shift;
|
||||
;;
|
||||
|
||||
-v|--verbose)
|
||||
VERBOSE=1;
|
||||
shift;
|
||||
;;
|
||||
|
||||
--)
|
||||
shift;
|
||||
break;
|
||||
;;
|
||||
|
||||
*)
|
||||
echo "Invalid Option ${1:-}";
|
||||
#ShowHelp
|
||||
shift; shift;
|
||||
return 1;
|
||||
;;
|
||||
|
||||
|
||||
esac
|
||||
done
|
||||
|
||||
}
|
||||
|
||||
RemoveBuildDir() {
|
||||
|
||||
if [ -d $SCRIPTPATH/Build ]; then
|
||||
Verbose Removing $SCRIPTPATH/Build directory
|
||||
rm $SCRIPTPATH/Build --recursive
|
||||
else
|
||||
Verbose $SCRIPTPATH/Build directory does not exist.
|
||||
|
||||
fi
|
||||
|
||||
}
|
||||
|
||||
CheckParams() {
|
||||
|
||||
if [ "${RESET:-}" == "1" ]; then
|
||||
RemoveBuildDir
|
||||
fi
|
||||
|
||||
if [ ! "${CMAKEHELP:-}" == "" ]; then
|
||||
cmake $CMAKEHELP
|
||||
Stop $?
|
||||
fi
|
||||
|
||||
}
|
||||
|
||||
|
||||
ShowInfo() {
|
||||
Debug Entering FUNCNAME "$FUNCNAME"
|
||||
|
||||
if [ "${SHOWINFO:-}" == "1" ]; then
|
||||
echo
|
||||
echo g++ version is...........$(g++ --version) | cut -c1-80
|
||||
echo cmake version is ........$(cmake --version) | cut -c1-80
|
||||
echo make version is..........$(make --version) | cut -c1-80
|
||||
echo
|
||||
fi
|
||||
|
||||
return 0
|
||||
|
||||
}
|
||||
|
||||
Generate() {
|
||||
Debug Entering FUNCNAME "$FUNCNAME"
|
||||
|
||||
local _err=0
|
||||
|
||||
# Be sure that we are actually in the root of our repo.
|
||||
pushd $SCRIPTPATH > /dev/null
|
||||
|
||||
_cmdstr='cmake ${FRESH:-} -G "${GENERATOR}" -S . -B Build '
|
||||
Verbose Executing "$_cmdstr"
|
||||
eval "$_cmdstr"
|
||||
_err=$?
|
||||
|
||||
popd > /dev/null
|
||||
|
||||
return $_err
|
||||
|
||||
}
|
||||
|
||||
|
||||
Build() {
|
||||
|
||||
if [ "${BUILD:-}" != "" ]; then
|
||||
pushd $SCRIPTPATH/Build > /dev/null
|
||||
make
|
||||
popd > /dev/null
|
||||
fi
|
||||
|
||||
|
||||
}
|
||||
|
||||
main () {
|
||||
|
||||
EchoSpacer "="
|
||||
ResetVars
|
||||
load_opts "$@"
|
||||
|
||||
#set -x
|
||||
ParseCommandLine "$@" || return 1
|
||||
CheckParams
|
||||
|
||||
ShowInfo
|
||||
Generate || return $?
|
||||
|
||||
Build
|
||||
|
||||
|
||||
|
||||
EchoSpacer "="
|
||||
|
||||
}
|
||||
|
||||
|
||||
main "$@"
|
||||
if [ $? -ne 0 ]; then echo "An error occurred."; fi
|
||||
set +x
|
223
CMakeLists.txt
223
CMakeLists.txt
@ -1,223 +0,0 @@
|
||||
##
|
||||
## THIS IS THE MASTER FILE
|
||||
## It contains some basic defaults and defintions that are inherited by the projects
|
||||
##
|
||||
|
||||
################################################################################
|
||||
# CONTENTS
|
||||
#
|
||||
# Project header
|
||||
# CMake globals
|
||||
# Project Settings
|
||||
# Options
|
||||
|
||||
# Targets
|
||||
|
||||
# Testing (TODO)
|
||||
# Packaging (TODO)
|
||||
################################################################################
|
||||
cmake_minimum_required(VERSION 3.25 FATAL_ERROR)
|
||||
set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_SOURCE_DIR}/cmake/")
|
||||
include(ConfigSafeGuards)
|
||||
|
||||
|
||||
################################################################################
|
||||
#
|
||||
# Project header
|
||||
#
|
||||
#################################################################################
|
||||
|
||||
# Suppress "Policy CMP0066 is not set"
|
||||
# This policy provides compatibility for projects that do not expect
|
||||
# config-specific compiler flags to be used.
|
||||
# See https://cmake.org/cmake/help/latest/policy/CMP0066.html
|
||||
#set (CMAKE_POLICY_WARNING_CMP0066 OFF)
|
||||
|
||||
|
||||
|
||||
|
||||
cmake_minimum_required(VERSION 3.10)
|
||||
|
||||
# tomsfastmath - modified from CMakeLists.txt created for libtomath
|
||||
project (TOMSFASTMATH
|
||||
VERSION 0.13.1
|
||||
DESCRIPTION "TomsFastMath is meant to be a very fast yet still fairly portable and easy to port large integer arithmetic library written in ISO C."
|
||||
HOMEPAGE_URL "https://github.com/libtom/tomsfastmath"
|
||||
LANGUAGES C)
|
||||
|
||||
# package release version
|
||||
# bump if re-releasing the same VERSION + patches
|
||||
# set to 1 if releasing a new VERSION
|
||||
set(PACKAGE_RELEASE_VERSION 1)
|
||||
################################################################################
|
||||
#
|
||||
# CMake Global Settings
|
||||
#
|
||||
################################################################################
|
||||
|
||||
# Allow use of function cmake_print_variables to print vars to output
|
||||
# See https://cmake.org/cmake/help/latest/module/CMakePrintHelpers.html
|
||||
include(CMakePrintHelpers)
|
||||
|
||||
|
||||
set(CMAKE_EXPORT_COMPILE_COMMANDS ON CACHE INTERNAL "Export compile_commands.json to support editors such as Kate, Visual Studio Code, Vim etc.")
|
||||
|
||||
set(CMAKE_VERBOSE_MAKEFILE ON CACHE INTERNAL "Generate verbose makefile")
|
||||
|
||||
# For tomsfastmath we use Build, although convention is to use all lowercase
|
||||
set(CMAKE_BINARY_DIR ${CMAKE_SOURCE_DIR}/Build)
|
||||
|
||||
|
||||
################################################################################
|
||||
#
|
||||
# Project Settings
|
||||
#
|
||||
#################################################################################
|
||||
|
||||
# Define build mode - this must be executed AFTER the project command otherwise
|
||||
# the cmake compiler will complain that CMAKE_BUILD_TYPE is uninitialised.
|
||||
message(STATUS "CMAKE_BUILD_TYPE is ${CMAKE_BUILD_TYPE}")
|
||||
if (NOT DEFINED CMAKE_BUILD_TYPE OR "${CMAKE_BUILD_TYPE}" STREQUAL "")
|
||||
set(CMAKE_BUILD_TYPE RelWithDebInfo CACHE STRING "Choose the type of build...")
|
||||
endif()
|
||||
|
||||
if ( UNIX )
|
||||
set(CMAKE_INSTALL_PREFIX /opt/fireswarm CACHE PATH "Default installation directory" FORCE)
|
||||
elseif ( WIN32 )
|
||||
set(CMAKE_INSTALL_PREFIX $ENV{ProgramFiles}/fireswarm CACHE PATH "Default installation directory" FORCE)
|
||||
endif()
|
||||
|
||||
|
||||
################################################################################
|
||||
#
|
||||
# Option Settings
|
||||
#
|
||||
#################################################################################
|
||||
|
||||
# ### Options: Things you can set via commandline options to cmake (e.g. -DTOMSFASTMATH_DISABLE_LIBCXX=[ON|OFF])
|
||||
|
||||
option(BUILD_SHARED_LIBS "Build shared library" ON)
|
||||
|
||||
option(TOMSFASTMATH_DISABLE_LIBCXX "Do not use libc++, even if available" ON)
|
||||
|
||||
option(ENABLE_WARNINGS_SETTINGS "Allow target_set_warnings to add flags and defines.
|
||||
Set this to OFF if you want to provide your own warning parameters.
|
||||
See cmake/Warnings.cmake for more info." ON)
|
||||
|
||||
option(ENABLE_LTO "Enable link time optimization" ON)
|
||||
|
||||
|
||||
include(LTO)
|
||||
include(Warnings)
|
||||
include(functions)
|
||||
include(sources)
|
||||
include(CompilerSettings)
|
||||
|
||||
# Check for LTO (Link-time optimisation) support.
|
||||
find_lto(CXX)
|
||||
|
||||
|
||||
include_directories( "src/" "src/headers" )
|
||||
include(cmake/sources.cmake)
|
||||
|
||||
# The only direct cmake argument for now
|
||||
option(BUILD_SHARED_LIBS "Build shared library and only the shared library if \"ON\", default is static" OFF)
|
||||
|
||||
#-----------------------------------------------------------------------------
|
||||
# Compose CFLAGS
|
||||
#-----------------------------------------------------------------------------
|
||||
|
||||
# Some information ported from makefile_include.mk
|
||||
|
||||
|
||||
if(NOT CMAKE_BUILD_TYPE AND NOT CMAKE_CONFIGURATION_TYPES)
|
||||
message(STATUS "Setting build type to 'Release' as none was specified.")
|
||||
set(CMAKE_BUILD_TYPE "Release")
|
||||
endif()
|
||||
|
||||
# We only differentiate between MSVC and GCC-compatible compilers
|
||||
if(MSVC)
|
||||
set(LTM_C_FLAGS -W3)
|
||||
elseif(WATCOM)
|
||||
set(LTM_C_FLAGS -fo=.obj -oaxt -3r -w3)
|
||||
else()
|
||||
set(LTM_C_FLAGS -Wall -Wsign-compare -Wextra -Wshadow
|
||||
-Wdeclaration-after-statement -Wbad-function-cast -Wcast-align
|
||||
-Wstrict-prototypes -Wpointer-arith -Wsystem-headers)
|
||||
set(CMAKE_C_FLAGS_DEBUG "-g3")
|
||||
set(CMAKE_C_FLAGS_RELEASE "-O3 -funroll-loops -fomit-frame-pointer")
|
||||
set(CMAKE_C_FLAGS_RELWITHDEBINFO "-g3 -O2")
|
||||
set(CMAKE_C_FLAGS_MINSIZEREL "-Os")
|
||||
endif()
|
||||
|
||||
# What compiler do we have and what are their...uhm... peculiarities
|
||||
if(CMAKE_C_COMPILER_ID MATCHES "(C|c?)lang")
|
||||
list(APPEND LTM_C_FLAGS -Wno-typedef-redefinition -Wno-tautological-compare -Wno-builtin-requires-header)
|
||||
# Clang requires at least '-O1' for dead code elimination
|
||||
set(CMAKE_C_FLAGS_DEBUG "-O1 ${CMAKE_C_FLAGS_DEBUG}")
|
||||
endif()
|
||||
if(CMAKE_C_COMPILER MATCHES "mingw")
|
||||
list(APPEND LTM_C_FLAGS -Wno-shadow -Wno-expansion-to-defined -Wno-declaration-after-statement -Wno-bad-function-cast)
|
||||
endif()
|
||||
if(CMAKE_SYSTEM_NAME MATCHES "Darwin")
|
||||
list(APPEND LTM_C_FLAGS -Wno-nullability-completeness)
|
||||
endif()
|
||||
if(CMAKE_SYSTEM_NAME MATCHES "CYGWIN")
|
||||
list(APPEND LTM_C_FLAGS -no-undefined)
|
||||
endif()
|
||||
|
||||
# TODO: coverage (lgcov)
|
||||
|
||||
# If the user set the environment variables at generate-time, append them
|
||||
# in order to allow overriding our defaults.
|
||||
# ${LTM_CFLAGS} means the user passed it via sth like:
|
||||
# $ cmake -DLTM_CFLAGS="foo"
|
||||
list(APPEND LTM_C_FLAGS ${LTM_CFLAGS})
|
||||
list(APPEND LTM_LD_FLAGS ${LTM_LDFLAGS})
|
||||
|
||||
#-----------------------------------------------------------------------------
|
||||
# library target
|
||||
#-----------------------------------------------------------------------------
|
||||
add_library( ${PROJECT_NAME} SHARED
|
||||
${TFM_SOURCE}
|
||||
${TFM_HEADERS}
|
||||
)
|
||||
|
||||
target_include_directories(${PROJECT_NAME} PUBLIC
|
||||
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}>
|
||||
$<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}/${PROJECT_NAME}>
|
||||
)
|
||||
|
||||
target_compile_options(${PROJECT_NAME} BEFORE PRIVATE
|
||||
${LTM_C_FLAGS}
|
||||
)
|
||||
target_link_options(${PROJECT_NAME} BEFORE PRIVATE
|
||||
${LTM_LD_FLAGS}
|
||||
)
|
||||
|
||||
set(PUBLIC_HEADERS tfm.h)
|
||||
|
||||
set_target_properties(${PROJECT_NAME} PROPERTIES
|
||||
OUTPUT_NAME tomsfastmath
|
||||
VERSION ${PROJECT_VERSION}
|
||||
SOVERSION ${PROJECT_VERSION_MAJOR}
|
||||
PUBLIC_HEADER "${PUBLIC_HEADERS}"
|
||||
)
|
||||
|
||||
option(COMPILE_LTO "Build with LTO enabled")
|
||||
if(COMPILE_LTO)
|
||||
check_ipo_supported(RESULT COMPILER_SUPPORTS_LTO)
|
||||
if(COMPILER_SUPPORTS_LTO)
|
||||
set_property(TARGET ${PROJECT_NAME} PROPERTY INTERPROCEDURAL_OPTIMIZATION TRUE)
|
||||
else()
|
||||
message(SEND_ERROR "This compiler does not support LTO. Reconfigure ${PROJECT_NAME} with -DCOMPILE_LTO=OFF.")
|
||||
endif()
|
||||
endif()
|
||||
|
||||
|
||||
|
||||
################################################################################
|
||||
################################################################################
|
||||
################################################################################
|
||||
################################################################################
|
||||
|
52
LICENSE
52
LICENSE
@ -1,26 +1,36 @@
|
||||
The LibTom license
|
||||
TomsFastMath is licensed under DUAL licensing terms.
|
||||
|
||||
This is free and unencumbered software released into the public domain.
|
||||
Choose and use the license of your needs.
|
||||
|
||||
Anyone is free to copy, modify, publish, use, compile, sell, or
|
||||
distribute this software, either in source code form or as a compiled
|
||||
binary, for any purpose, commercial or non-commercial, and by any
|
||||
means.
|
||||
[LICENSE #1]
|
||||
|
||||
In jurisdictions that recognize copyright laws, the author or authors
|
||||
of this software dedicate any and all copyright interest in the
|
||||
software to the public domain. We make this dedication for the benefit
|
||||
of the public at large and to the detriment of our heirs and
|
||||
successors. We intend this dedication to be an overt act of
|
||||
relinquishment in perpetuity of all present and future rights to this
|
||||
software under copyright law.
|
||||
TomsFastMath is public domain. As should all quality software be.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
|
||||
IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR
|
||||
OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
|
||||
ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
|
||||
OTHER DEALINGS IN THE SOFTWARE.
|
||||
Tom St Denis
|
||||
|
||||
For more information, please refer to <http://unlicense.org/>
|
||||
[/LICENSE #1]
|
||||
|
||||
[LICENSE #2]
|
||||
|
||||
DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE
|
||||
Version 2, December 2004
|
||||
|
||||
Copyright (C) 2004 Sam Hocevar <sam@hocevar.net>
|
||||
|
||||
Everyone is permitted to copy and distribute verbatim or modified
|
||||
copies of this license document, and changing it is allowed as long
|
||||
as the name is changed.
|
||||
|
||||
DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE
|
||||
TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
|
||||
|
||||
0. You just DO WHAT THE FUCK YOU WANT TO.
|
||||
|
||||
[/LICENSE #2]
|
||||
|
||||
-- Mark Karpelès & Steffen Jaeckel
|
||||
|
||||
Note some ideas were borrowed from LibTomMath and OpenSSL. All of the code is original or ported
|
||||
from LibTomMath [no code was ported from OpenSSL].
|
||||
|
||||
-- Tom St Denis
|
||||
|
@ -1,54 +0,0 @@
|
||||
################################################################################
|
||||
#
|
||||
# Compiler Settings
|
||||
#
|
||||
################################################################################
|
||||
|
||||
# Require and enable C++ 0x/11/14/17
|
||||
set(CMAKE_CXX_STANDARD 17)
|
||||
set(CMAKE_CXX_STANDARD_REQUIRED ON)
|
||||
set(CMAKE_CXX_EXTENSIONS OFF)
|
||||
message(STATUS "tomsfastmath pre-check compiler: C++${CMAKE_CXX_STANDARD} with CMAKE_CXX_FLAGS ${CMAKE_CXX_FLAGS} ")
|
||||
|
||||
if(CMAKE_CXX_COMPILER_ID MATCHES "Clang" OR CMAKE_COMPILER_IS_GNUCXX)
|
||||
# set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -Wnarrowing -Werror ")
|
||||
# set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -Werror -Wnarrowing -Wextra")
|
||||
set(CMAKE_CXX_FLAGS " -Werror -Wshadow -Wextra -Wall -fexceptions -fno-omit-frame-pointer -fno-rtti -DUNICODE ${CMAKE_CXX_FLAGS} ")
|
||||
set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} -s")
|
||||
include(CheckCXXCompilerFlag)
|
||||
if(NOT TOMSFASTMATH_DISABLE_LIBCXX)
|
||||
check_cxx_compiler_flag("-stdlib=libc++" CXX_SUPPORTS_STDLIB)
|
||||
if(CXX_SUPPORTS_STDLIB)
|
||||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -stdlib=libc++")
|
||||
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -stdlib=libc++")
|
||||
set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} -stdlib=libc++")
|
||||
set(CMAKE_MODULE_LINKER_FLAGS "${CMAKE_MODULE_LINKER_FLAGS} -stdlib=libc++")
|
||||
endif()
|
||||
set(TOMSFASTMATH_DISABLE_LIBCXX ${TOMSFASTMATH_DISABLE_LIBCXX} CACHE BOOL "Do not use libc++, if available." FORCE)
|
||||
endif()
|
||||
message(STATUS "tomsfastmath build: Disable linking libc++ - ${TOMSFASTMATH_DISABLE_LIBCXX}")
|
||||
elseif(CMAKE_CXX_COMPILER_ID MATCHES "Intel")
|
||||
string(REGEX REPLACE "[/-]W[0-4]" "/W4" CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS}")
|
||||
if (NOT (CMAKE_VERSION VERSION_LESS 3.6.0)) # Compiler features for Intel in CMake 3.6+
|
||||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /Qstd=c++17")
|
||||
endif()
|
||||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /QaxCORE-AVX2")
|
||||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /fp:precise")
|
||||
set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} /Od")
|
||||
set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} /O3")
|
||||
set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} /Qipo")
|
||||
elseif(MSVC)
|
||||
string(REGEX REPLACE "/W[0-4]" "/W4" CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS}")
|
||||
if(MSVC_VERSION LESS 1900)
|
||||
message(FATAL_ERROR "tomsfastmath : Build requires C++17-compliant compiler")
|
||||
endif()
|
||||
endif()
|
||||
|
||||
if(CMAKE_BUILD_TYPE MATCHES Debug)
|
||||
message(STATUS "tomsfastmath : Global compiler flags - ${CMAKE_CXX_FLAGS} ${CMAKE_CXX_FLAGS_DEBUG}")
|
||||
elseif(CMAKE_BUILD_TYPE MATCHES RelWithDebInfo)
|
||||
message(STATUS "tomsfastmath : Global compiler flags - ${CMAKE_CXX_FLAGS} ${CMAKE_CXX_FLAGS_RELWITHDEBINFO}")
|
||||
elseif(CMAKE_BUILD_TYPE MATCHES Release)
|
||||
message(STATUS "tomsfastmath : Global compiler flags - ${CMAKE_CXX_FLAGS} ${CMAKE_CXX_FLAGS_RELEASE}")
|
||||
endif()
|
||||
|
@ -1,22 +0,0 @@
|
||||
# https://github.com/bsamseth/cpp-project
|
||||
|
||||
# guard against in-source builds
|
||||
if(${CMAKE_SOURCE_DIR} STREQUAL ${CMAKE_BINARY_DIR})
|
||||
message(FATAL_ERROR "In-source builds not allowed. Please make a new directory (called a build directory) and run CMake from there.")
|
||||
endif()
|
||||
|
||||
# guard against bad build-type strings
|
||||
if (NOT CMAKE_BUILD_TYPE)
|
||||
message(STATUS "No build type selected, default to Debug")
|
||||
set(CMAKE_BUILD_TYPE "RelWithDebInfo")
|
||||
endif()
|
||||
|
||||
string(TOLOWER "${CMAKE_BUILD_TYPE}" cmake_build_type_tolower)
|
||||
string(TOUPPER "${CMAKE_BUILD_TYPE}" cmake_build_type_toupper)
|
||||
if( NOT cmake_build_type_tolower STREQUAL "debug"
|
||||
AND NOT cmake_build_type_tolower STREQUAL "release"
|
||||
AND NOT cmake_build_type_tolower STREQUAL "profile"
|
||||
AND NOT cmake_build_type_tolower STREQUAL "relwithdebinfo"
|
||||
AND NOT cmake_build_type_tolower STREQUAL "coverage")
|
||||
message(FATAL_ERROR "Unknown build type \"${CMAKE_BUILD_TYPE}\". Allowed values are Debug, Coverage, Release, Profile, RelWithDebInfo (case-insensitive).")
|
||||
endif()
|
255
cmake/LTO.cmake
255
cmake/LTO.cmake
@ -1,255 +0,0 @@
|
||||
################################################################################
|
||||
#
|
||||
# LTO - Link-time optimisation
|
||||
#
|
||||
################################################################################
|
||||
#
|
||||
# Usage :
|
||||
#
|
||||
# Variable : ENABLE_LTO | Enable or disable LTO support for this build
|
||||
#
|
||||
# find_lto(lang)
|
||||
# - lang is C or CXX (the language to test LTO for)
|
||||
# - call it after project() so that the compiler is already detected
|
||||
#
|
||||
# This will check for LTO support and create a target_enable_lto(target [debug,optimized,general]) macro.
|
||||
# The 2nd parameter has the same meaning as in target_link_libraries, and is used to enable LTO only for those build configurations
|
||||
# 'debug' is by default the Debug configuration, and 'optimized' all the other configurations
|
||||
#
|
||||
# if ENABLE_LTO is set to false, an empty macro will be generated
|
||||
#
|
||||
# Then to enable LTO for your target use
|
||||
#
|
||||
# target_enable_lto(mytarget general)
|
||||
#
|
||||
# It is however recommended to use it only for non debug builds the following way :
|
||||
#
|
||||
# target_enable_lto(mytarget optimized)
|
||||
#
|
||||
# Note : For CMake versions < 3.9, target_link_library is used in it's non plain version.
|
||||
# You will need to specify PUBLIC/PRIVATE/INTERFACE to all your other target_link_library calls for the target
|
||||
#
|
||||
# WARNING for cmake versions older than 3.9 :
|
||||
# This module will override CMAKE_AR CMAKE_RANLIB and CMAKE_NM by the gcc versions if found when building with gcc
|
||||
|
||||
|
||||
# License:
|
||||
#
|
||||
# Copyright (C) 2016 Lectem <lectem@gmail.com>
|
||||
#
|
||||
# Permission is hereby granted, free of charge, to any person
|
||||
# obtaining a copy of this software and associated documentation files
|
||||
# (the 'Software') deal in the Software without restriction,
|
||||
# including without limitation the rights to use, copy, modify, merge,
|
||||
# publish, distribute, sublicense, and/or sell copies of the Software,
|
||||
# and to permit persons to whom the Software is furnished to do so,
|
||||
# subject to the following conditions:
|
||||
#
|
||||
# The above copyright notice and this permission notice shall be
|
||||
# included in all copies or substantial portions of the Software.
|
||||
#
|
||||
# THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND,
|
||||
# EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
||||
# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
|
||||
# BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
|
||||
# ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
|
||||
# CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
# SOFTWARE.
|
||||
|
||||
|
||||
macro(find_lto lang)
|
||||
if(ENABLE_LTO AND NOT LTO_${lang}_CHECKED)
|
||||
|
||||
#LTO support was added for clang/gcc in 3.9
|
||||
if(${CMAKE_MAJOR_VERSION}.${CMAKE_MINOR_VERSION} VERSION_LESS 3.9)
|
||||
cmake_policy(SET CMP0054 NEW)
|
||||
message(STATUS "Checking for LTO Compatibility")
|
||||
# Since GCC 4.9 we need to use gcc-ar / gcc-ranlib / gcc-nm
|
||||
if(CMAKE_CXX_COMPILER_ID STREQUAL "GNU" OR CMAKE_CXX_COMPILER_ID MATCHES "Clang")
|
||||
if(CMAKE_CXX_COMPILER_ID STREQUAL "GNU" AND NOT CMAKE_GCC_AR OR NOT CMAKE_GCC_RANLIB OR NOT CMAKE_GCC_NM)
|
||||
find_program(CMAKE_GCC_AR NAMES
|
||||
"${_CMAKE_TOOLCHAIN_PREFIX}gcc-ar"
|
||||
"${_CMAKE_TOOLCHAIN_PREFIX}gcc-ar-${_version}"
|
||||
DOC "gcc provided wrapper for ar which adds the --plugin option"
|
||||
)
|
||||
find_program(CMAKE_GCC_RANLIB NAMES
|
||||
"${_CMAKE_TOOLCHAIN_PREFIX}gcc-ranlib"
|
||||
"${_CMAKE_TOOLCHAIN_PREFIX}gcc-ranlib-${_version}"
|
||||
DOC "gcc provided wrapper for ranlib which adds the --plugin option"
|
||||
)
|
||||
# Not needed, but at least stay coherent
|
||||
find_program(CMAKE_GCC_NM NAMES
|
||||
"${_CMAKE_TOOLCHAIN_PREFIX}gcc-nm"
|
||||
"${_CMAKE_TOOLCHAIN_PREFIX}gcc-nm-${_version}"
|
||||
DOC "gcc provided wrapper for nm which adds the --plugin option"
|
||||
)
|
||||
mark_as_advanced(CMAKE_GCC_AR CMAKE_GCC_RANLIB CMAKE_GCC_NM)
|
||||
set(CMAKE_LTO_AR ${CMAKE_GCC_AR})
|
||||
set(CMAKE_LTO_RANLIB ${CMAKE_GCC_RANLIB})
|
||||
set(CMAKE_LTO_NM ${CMAKE_GCC_NM})
|
||||
endif()
|
||||
if("${CMAKE_CXX_COMPILER_ID}" MATCHES "Clang")
|
||||
set(CMAKE_LTO_AR ${CMAKE_AR})
|
||||
set(CMAKE_LTO_RANLIB ${CMAKE_RANLIB})
|
||||
set(CMAKE_LTO_NM ${CMAKE_NM})
|
||||
endif()
|
||||
|
||||
if(CMAKE_LTO_AR AND CMAKE_LTO_RANLIB)
|
||||
set(__lto_flags -flto)
|
||||
|
||||
if(NOT CMAKE_${lang}_COMPILER_VERSION VERSION_LESS 4.7)
|
||||
list(APPEND __lto_flags -fno-fat-lto-objects)
|
||||
endif()
|
||||
|
||||
if(NOT DEFINED CMAKE_${lang}_PASSED_LTO_TEST)
|
||||
set(__output_dir "${CMAKE_PLATFORM_INFO_DIR}/LtoTest1${lang}")
|
||||
file(MAKE_DIRECTORY "${__output_dir}")
|
||||
set(__output_base "${__output_dir}/lto-test-${lang}")
|
||||
|
||||
execute_process(
|
||||
COMMAND ${CMAKE_COMMAND} -E echo "void foo() {}"
|
||||
COMMAND ${CMAKE_${lang}_COMPILER} ${__lto_flags} -c -xc -
|
||||
-o "${__output_base}.o"
|
||||
RESULT_VARIABLE __result
|
||||
ERROR_QUIET
|
||||
OUTPUT_QUIET
|
||||
)
|
||||
|
||||
if("${__result}" STREQUAL "0")
|
||||
execute_process(
|
||||
COMMAND ${CMAKE_LTO_AR} cr "${__output_base}.a" "${__output_base}.o"
|
||||
RESULT_VARIABLE __result
|
||||
ERROR_QUIET
|
||||
OUTPUT_QUIET
|
||||
)
|
||||
endif()
|
||||
|
||||
if("${__result}" STREQUAL "0")
|
||||
execute_process(
|
||||
COMMAND ${CMAKE_LTO_RANLIB} "${__output_base}.a"
|
||||
RESULT_VARIABLE __result
|
||||
ERROR_QUIET
|
||||
OUTPUT_QUIET
|
||||
)
|
||||
endif()
|
||||
|
||||
if("${__result}" STREQUAL "0")
|
||||
execute_process(
|
||||
COMMAND ${CMAKE_COMMAND} -E echo "void foo(); int main() {foo();}"
|
||||
COMMAND ${CMAKE_${lang}_COMPILER} ${__lto_flags} -xc -
|
||||
-x none "${__output_base}.a" -o "${__output_base}"
|
||||
RESULT_VARIABLE __result
|
||||
ERROR_QUIET
|
||||
OUTPUT_QUIET
|
||||
)
|
||||
endif()
|
||||
|
||||
if("${__result}" STREQUAL "0")
|
||||
set(__lto_found TRUE)
|
||||
endif()
|
||||
|
||||
set(CMAKE_${lang}_PASSED_LTO_TEST
|
||||
${__lto_found} CACHE INTERNAL
|
||||
"If the compiler passed a simple LTO test compile")
|
||||
endif()
|
||||
if(CMAKE_${lang}_PASSED_LTO_TEST)
|
||||
message(STATUS "Checking for LTO Compatibility - works")
|
||||
set(LTO_${lang}_SUPPORT TRUE CACHE BOOL "Do we have LTO support ?")
|
||||
set(LTO_COMPILE_FLAGS -flto CACHE STRING "Link Time Optimization compile flags")
|
||||
set(LTO_LINK_FLAGS -flto CACHE STRING "Link Time Optimization link flags")
|
||||
else()
|
||||
message(STATUS "Checking for LTO Compatibility - not working")
|
||||
endif()
|
||||
|
||||
endif()
|
||||
elseif(CMAKE_CXX_COMPILER_ID MATCHES "Clang")
|
||||
message(STATUS "Checking for LTO Compatibility - works (assumed for clang)")
|
||||
set(LTO_${lang}_SUPPORT TRUE CACHE BOOL "Do we have LTO support ?")
|
||||
set(LTO_COMPILE_FLAGS -flto CACHE STRING "Link Time Optimization compile flags")
|
||||
set(LTO_LINK_FLAGS -flto CACHE STRING "Link Time Optimization link flags")
|
||||
elseif(CMAKE_CXX_COMPILER_ID STREQUAL "MSVC")
|
||||
message(STATUS "Checking for LTO Compatibility - works")
|
||||
set(LTO_${lang}_SUPPORT TRUE CACHE BOOL "Do we have LTO support ?")
|
||||
set(LTO_COMPILE_FLAGS /GL CACHE STRING "Link Time Optimization compile flags")
|
||||
set(LTO_LINK_FLAGS -LTCG:INCREMENTAL CACHE STRING "Link Time Optimization link flags")
|
||||
else()
|
||||
message(STATUS "Checking for LTO Compatibility - compiler not handled by module")
|
||||
endif()
|
||||
mark_as_advanced(LTO_${lang}_SUPPORT LTO_COMPILE_FLAGS LTO_LINK_FLAGS)
|
||||
|
||||
|
||||
set(LTO_${lang}_CHECKED TRUE CACHE INTERNAL "" )
|
||||
|
||||
if(CMAKE_GCC_AR AND CMAKE_GCC_RANLIB AND CMAKE_GCC_NM)
|
||||
# THIS IS HACKY BUT THERE IS NO OTHER SOLUTION ATM
|
||||
set(CMAKE_AR ${CMAKE_GCC_AR} CACHE FILEPATH "Forcing gcc-ar instead of ar" FORCE)
|
||||
set(CMAKE_NM ${CMAKE_GCC_NM} CACHE FILEPATH "Forcing gcc-nm instead of nm" FORCE)
|
||||
set(CMAKE_RANLIB ${CMAKE_GCC_RANLIB} CACHE FILEPATH "Forcing gcc-ranlib instead of ranlib" FORCE)
|
||||
endif()
|
||||
endif(${CMAKE_MAJOR_VERSION}.${CMAKE_MINOR_VERSION} VERSION_LESS 3.9)
|
||||
endif(ENABLE_LTO AND NOT LTO_${lang}_CHECKED)
|
||||
|
||||
|
||||
if(ENABLE_LTO)
|
||||
#Special case for cmake older than 3.9, using a library for gcc/clang, but could setup the flags directly.
|
||||
#Taking advantage of the [debug,optimized] parameter of target_link_libraries
|
||||
if(${CMAKE_MAJOR_VERSION}.${CMAKE_MINOR_VERSION} VERSION_LESS 3.9)
|
||||
if(LTO_${lang}_SUPPORT)
|
||||
if(NOT TARGET __enable_lto_tgt)
|
||||
add_library(__enable_lto_tgt INTERFACE)
|
||||
endif()
|
||||
target_compile_options(__enable_lto_tgt INTERFACE ${LTO_COMPILE_FLAGS})
|
||||
#this might not work for all platforms... in which case we'll have to set the link flags on the target directly
|
||||
target_link_libraries(__enable_lto_tgt INTERFACE ${LTO_LINK_FLAGS} )
|
||||
macro(target_enable_lto _target _build_configuration)
|
||||
if(${_build_configuration} STREQUAL "optimized" OR ${_build_configuration} STREQUAL "debug" )
|
||||
target_link_libraries(${_target} PRIVATE ${_build_configuration} __enable_lto_tgt)
|
||||
else()
|
||||
target_link_libraries(${_target} PRIVATE __enable_lto_tgt)
|
||||
endif()
|
||||
endmacro()
|
||||
else()
|
||||
#In old cmake versions, we can set INTERPROCEDURAL_OPTIMIZATION even if not supported by the compiler
|
||||
#So if we didn't detect it, let cmake give it a try
|
||||
set(__IPO_SUPPORTED TRUE)
|
||||
endif()
|
||||
else()
|
||||
cmake_policy(SET CMP0069 NEW)
|
||||
include(CheckIPOSupported)
|
||||
# Optional IPO. Do not use IPO if it's not supported by compiler.
|
||||
check_ipo_supported(RESULT __IPO_SUPPORTED OUTPUT output)
|
||||
if(NOT __IPO_SUPPORTED)
|
||||
message(STATUS "IPO (interprocedural optimization) is not supported or broken.")
|
||||
else()
|
||||
message(STATUS "IPO (interprocedural optimization) is supported")
|
||||
endif()
|
||||
endif()
|
||||
if(__IPO_SUPPORTED)
|
||||
macro(target_enable_lto _target _build_configuration)
|
||||
if(NOT ${_build_configuration} STREQUAL "debug" )
|
||||
#enable for all configurations
|
||||
set_target_properties(${_target} PROPERTIES INTERPROCEDURAL_OPTIMIZATION TRUE)
|
||||
endif()
|
||||
if(${_build_configuration} STREQUAL "optimized" )
|
||||
#blacklist debug configurations
|
||||
set(__enable_debug_lto FALSE)
|
||||
else()
|
||||
#enable only for debug configurations
|
||||
set(__enable_debug_lto TRUE)
|
||||
endif()
|
||||
get_property(DEBUG_CONFIGURATIONS GLOBAL PROPERTY DEBUG_CONFIGURATIONS)
|
||||
if(NOT DEBUG_CONFIGURATIONS)
|
||||
set(DEBUG_CONFIGURATIONS DEBUG) # This is what is done by CMAKE internally... since DEBUG_CONFIGURATIONS is empty by default
|
||||
endif()
|
||||
foreach(config IN LISTS DEBUG_CONFIGURATIONS)
|
||||
set_target_properties(${_target} PROPERTIES INTERPROCEDURAL_OPTIMIZATION_${config} ${__enable_debug_lto})
|
||||
endforeach()
|
||||
endmacro()
|
||||
endif()
|
||||
endif()
|
||||
if(NOT COMMAND target_enable_lto)
|
||||
macro(target_enable_lto _target _build_configuration)
|
||||
endmacro()
|
||||
endif()
|
||||
endmacro()
|
@ -1,100 +0,0 @@
|
||||
# MIT License
|
||||
#
|
||||
# Copyright (c) 2017 Lectem
|
||||
#
|
||||
# Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
# of this software and associated documentation files (the "Software"), to deal
|
||||
# in the Software without restriction, including without limitation the rights
|
||||
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
# copies of the Software, and to permit persons to whom the Software is
|
||||
# furnished to do so, subject to the following conditions:
|
||||
#
|
||||
# The above copyright notice and this permission notice shall be included in all
|
||||
# copies or substantial portions of the Software.
|
||||
#
|
||||
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
# SOFTWARE.
|
||||
|
||||
function(target_set_warnings)
|
||||
if(NOT ENABLE_WARNINGS_SETTINGS)
|
||||
return()
|
||||
endif()
|
||||
if ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "MSVC")
|
||||
set(WMSVC TRUE)
|
||||
elseif ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "GNU")
|
||||
set(WGCC TRUE)
|
||||
elseif ("${CMAKE_CXX_COMPILER_ID}" MATCHES "Clang")
|
||||
set(WCLANG TRUE)
|
||||
endif()
|
||||
set(multiValueArgs ENABLE DISABLE AS_ERROR)
|
||||
cmake_parse_arguments(this "" "" "${multiValueArgs}" ${ARGN})
|
||||
list(FIND this_ENABLE "ALL" enable_all)
|
||||
list(FIND this_DISABLE "ALL" disable_all)
|
||||
list(FIND this_AS_ERROR "ALL" as_error_all)
|
||||
if(NOT ${enable_all} EQUAL -1)
|
||||
if(WMSVC)
|
||||
# Not all the warnings, but WAll is unusable when using libraries
|
||||
# Unless you'd like to support MSVC in the code with pragmas, this is probably the best option
|
||||
list(APPEND WarningFlags "/W4")
|
||||
elseif(WGCC)
|
||||
list(APPEND WarningFlags "-Wall" "-Wextra" "-Wpedantic")
|
||||
elseif(WCLANG)
|
||||
list(APPEND WarningFlags "-Wall" "-Weverything" "-Wpedantic")
|
||||
endif()
|
||||
elseif(NOT ${disable_all} EQUAL -1)
|
||||
set(SystemIncludes TRUE) # Treat includes as if coming from system
|
||||
if(WMSVC)
|
||||
list(APPEND WarningFlags "/w" "/W0")
|
||||
elseif(WGCC OR WCLANG)
|
||||
list(APPEND WarningFlags "-w")
|
||||
endif()
|
||||
endif()
|
||||
|
||||
list(FIND this_DISABLE "Annoying" disable_annoying)
|
||||
if(NOT ${disable_annoying} EQUAL -1)
|
||||
if(WMSVC)
|
||||
# bounds-checked functions require to set __STDC_WANT_LIB_EXT1__ which we usually don't need/want
|
||||
list(APPEND WarningDefinitions -D_CRT_SECURE_NO_WARNINGS)
|
||||
# disable C4514 C4710 C4711... Those are useless to add most of the time
|
||||
#list(APPEND WarningFlags "/wd4514" "/wd4710" "/wd4711")
|
||||
#list(APPEND WarningFlags "/wd4365") #signed/unsigned mismatch
|
||||
#list(APPEND WarningFlags "/wd4668") # is not defined as a preprocessor macro, replacing with '0' for
|
||||
elseif(WGCC OR WCLANG)
|
||||
list(APPEND WarningFlags -Wno-switch-enum)
|
||||
if(WCLANG)
|
||||
list(APPEND WarningFlags -Wno-unknown-warning-option -Wno-padded -Wno-undef -Wno-reserved-id-macro -fcomment-block-commands=test,retval)
|
||||
if(NOT CMAKE_CXX_STANDARD EQUAL 98)
|
||||
list(APPEND WarningFlags -Wno-c++98-compat -Wno-c++98-compat-pedantic)
|
||||
endif()
|
||||
if ("${CMAKE_CXX_SIMULATE_ID}" STREQUAL "MSVC") # clang-cl has some VCC flags by default that it will not recognize...
|
||||
list(APPEND WarningFlags -Wno-unused-command-line-argument)
|
||||
endif()
|
||||
endif(WCLANG)
|
||||
endif()
|
||||
endif()
|
||||
|
||||
if(NOT ${as_error_all} EQUAL -1)
|
||||
if(WMSVC)
|
||||
list(APPEND WarningFlags "/WX")
|
||||
elseif(WGCC OR WCLANG)
|
||||
list(APPEND WarningFlags "-Werror")
|
||||
endif()
|
||||
endif()
|
||||
foreach(target IN LISTS this_UNPARSED_ARGUMENTS)
|
||||
if(WarningFlags)
|
||||
target_compile_options(${target} PRIVATE ${WarningFlags})
|
||||
endif()
|
||||
if(WarningDefinitions)
|
||||
target_compile_definitions(${target} PRIVATE ${WarningDefinitions})
|
||||
endif()
|
||||
if(SystemIncludes)
|
||||
set_target_properties(${target} PROPERTIES
|
||||
INTERFACE_SYSTEM_INCLUDE_DIRECTORIES $<TARGET_PROPERTY:${target},INTERFACE_INCLUDE_DIRECTORIES>)
|
||||
endif()
|
||||
endforeach()
|
||||
endfunction(target_set_warnings)
|
@ -1,13 +0,0 @@
|
||||
# ##############################################################################
|
||||
# cmake function library
|
||||
# ##############################################################################
|
||||
|
||||
# Taken from https://jeremimucha.com/2021/01/cmake-fundamentals-part3/
|
||||
# See also https://jeremimucha.com/2021/02/cmake-functions-and-macros/
|
||||
function(PrintTargetLibraries target msg)
|
||||
get_target_property(linkedLibs ${target} LINK_LIBRARIES)
|
||||
get_target_property(interfaceLibs ${target} INTERFACE_LINK_LIBRARIES)
|
||||
message(STATUS "${msg}")
|
||||
message(STATUS "${target} LINK_LIBRARIES: ${linkedLibs}")
|
||||
message(STATUS "${target} INTERFACE_LINK_LIBRARIES: ${interfaceLibs}")
|
||||
endfunction()
|
@ -1,121 +0,0 @@
|
||||
# ### ###########################################################################
|
||||
# ### Definitions taken from CMakeLists.txt for tomsfastmath in ClamAV
|
||||
# ### https://github.com/Cisco-Talos/clamav/blob/main/libclamav/CMakeLists.txt
|
||||
# ### ###########################################################################
|
||||
|
||||
# Enable overflow checks in TomsFastMath's fp_exptmod() function.
|
||||
add_definitions(-DTFM_CHECK)
|
||||
|
||||
# Just enable ASM in in TomsFastMath's on x86-64 where we know it works.
|
||||
# on i686 we run out of registers with -fPIC, and on ia64 we miscompile.
|
||||
if(NOT CMAKE_COMPILER_IS_GNUCC OR NOT (CMAKE_SIZEOF_VOID_P EQUAL 8))
|
||||
add_definitions(-DTFM_NO_ASM)
|
||||
endif()
|
||||
|
||||
# ### ###########################################################################
|
||||
# ### SOURCES and HEADERS
|
||||
# ### ###########################################################################
|
||||
|
||||
# to generate the source list cd to extern/tomsfastmath and execute:
|
||||
# `find -type f -name *.c | grep -v generators |sort | cut -c 3- | awk '{ print "\"../src/"$0"\""}' > sources.txt`
|
||||
# then copy/paste here as required.
|
||||
|
||||
set ( TFM_SOURCE
|
||||
"../src/addsub/fp_add.c"
|
||||
"../src/addsub/fp_add_d.c"
|
||||
"../src/addsub/fp_addmod.c"
|
||||
"../src/addsub/fp_cmp.c"
|
||||
"../src/addsub/fp_cmp_d.c"
|
||||
"../src/addsub/fp_cmp_mag.c"
|
||||
"../src/addsub/fp_sub.c"
|
||||
"../src/addsub/fp_sub_d.c"
|
||||
"../src/addsub/fp_submod.c"
|
||||
"../src/addsub/s_fp_add.c"
|
||||
"../src/addsub/s_fp_sub.c"
|
||||
"../src/bin/fp_radix_size.c"
|
||||
"../src/bin/fp_read_radix.c"
|
||||
"../src/bin/fp_read_signed_bin.c"
|
||||
"../src/bin/fp_read_unsigned_bin.c"
|
||||
"../src/bin/fp_reverse.c"
|
||||
"../src/bin/fp_signed_bin_size.c"
|
||||
"../src/bin/fp_s_rmap.c"
|
||||
"../src/bin/fp_toradix.c"
|
||||
"../src/bin/fp_toradix_n.c"
|
||||
"../src/bin/fp_to_signed_bin.c"
|
||||
"../src/bin/fp_to_unsigned_bin.c"
|
||||
"../src/bin/fp_unsigned_bin_size.c"
|
||||
"../src/bit/fp_cnt_lsb.c"
|
||||
"../src/bit/fp_count_bits.c"
|
||||
"../src/bit/fp_div_2.c"
|
||||
"../src/bit/fp_div_2d.c"
|
||||
"../src/bit/fp_lshd.c"
|
||||
"../src/bit/fp_mod_2d.c"
|
||||
"../src/bit/fp_rshd.c"
|
||||
"../src/divide/fp_div.c"
|
||||
"../src/divide/fp_div_d.c"
|
||||
"../src/divide/fp_mod.c"
|
||||
"../src/divide/fp_mod_d.c"
|
||||
"../src/exptmod/fp_2expt.c"
|
||||
"../src/exptmod/fp_exptmod.c"
|
||||
"../src/misc/fp_ident.c"
|
||||
"../src/misc/fp_rand.c"
|
||||
"../src/misc/fp_set.c"
|
||||
"../src/mont/fp_montgomery_calc_normalization.c"
|
||||
"../src/mont/fp_montgomery_reduce.c"
|
||||
"../src/mont/fp_montgomery_setup.c"
|
||||
"../src/mul/fp_mul_2.c"
|
||||
"../src/mul/fp_mul_2d.c"
|
||||
"../src/mul/fp_mul.c"
|
||||
"../src/mul/fp_mul_comba_12.c"
|
||||
"../src/mul/fp_mul_comba_17.c"
|
||||
"../src/mul/fp_mul_comba_20.c"
|
||||
"../src/mul/fp_mul_comba_24.c"
|
||||
"../src/mul/fp_mul_comba_28.c"
|
||||
"../src/mul/fp_mul_comba_32.c"
|
||||
"../src/mul/fp_mul_comba_3.c"
|
||||
"../src/mul/fp_mul_comba_48.c"
|
||||
"../src/mul/fp_mul_comba_4.c"
|
||||
"../src/mul/fp_mul_comba_64.c"
|
||||
"../src/mul/fp_mul_comba_6.c"
|
||||
"../src/mul/fp_mul_comba_7.c"
|
||||
"../src/mul/fp_mul_comba_8.c"
|
||||
"../src/mul/fp_mul_comba_9.c"
|
||||
"../src/mul/fp_mul_comba.c"
|
||||
"../src/mul/fp_mul_comba_small_set.c"
|
||||
"../src/mul/fp_mul_d.c"
|
||||
"../src/mul/fp_mulmod.c"
|
||||
"../src/numtheory/fp_gcd.c"
|
||||
"../src/numtheory/fp_invmod.c"
|
||||
"../src/numtheory/fp_isprime.c"
|
||||
"../src/numtheory/fp_isprime_ex.c"
|
||||
"../src/numtheory/fp_lcm.c"
|
||||
"../src/numtheory/fp_prime_miller_rabin.c"
|
||||
"../src/numtheory/fp_prime_random_ex.c"
|
||||
"../src/sqr/fp_sqr.c"
|
||||
"../src/sqr/fp_sqr_comba_12.c"
|
||||
"../src/sqr/fp_sqr_comba_17.c"
|
||||
"../src/sqr/fp_sqr_comba_20.c"
|
||||
"../src/sqr/fp_sqr_comba_24.c"
|
||||
"../src/sqr/fp_sqr_comba_28.c"
|
||||
"../src/sqr/fp_sqr_comba_32.c"
|
||||
"../src/sqr/fp_sqr_comba_3.c"
|
||||
"../src/sqr/fp_sqr_comba_48.c"
|
||||
"../src/sqr/fp_sqr_comba_4.c"
|
||||
"../src/sqr/fp_sqr_comba_64.c"
|
||||
"../src/sqr/fp_sqr_comba_6.c"
|
||||
"../src/sqr/fp_sqr_comba_7.c"
|
||||
"../src/sqr/fp_sqr_comba_8.c"
|
||||
"../src/sqr/fp_sqr_comba_9.c"
|
||||
"../src/sqr/fp_sqr_comba.c"
|
||||
"../src/sqr/fp_sqr_comba_generic.c"
|
||||
"../src/sqr/fp_sqr_comba_small_set.c"
|
||||
"../src/sqr/fp_sqrmod.c"
|
||||
|
||||
|
||||
)
|
||||
|
||||
set ( TFM_HEADERS
|
||||
"../src/headers/tfm.h"
|
||||
# "tfm_private.h"
|
||||
)
|
||||
|
@ -1,6 +1,3 @@
|
||||
/* TomsFastMath, a fast ISO C bignum library. -- Tom St Denis */
|
||||
/* SPDX-License-Identifier: Unlicense */
|
||||
|
||||
#include "tfm.h"
|
||||
#include <time.h>
|
||||
|
||||
@ -80,3 +77,7 @@ int main(void)
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* $Source$ */
|
||||
/* $Revision$ */
|
||||
/* $Date$ */
|
||||
|
@ -1,6 +1,3 @@
|
||||
/* TomsFastMath, a fast ISO C bignum library. -- Tom St Denis */
|
||||
/* SPDX-License-Identifier: Unlicense */
|
||||
|
||||
/* A simple static test program. */
|
||||
#include <tfm.h>
|
||||
|
||||
@ -183,3 +180,8 @@ int main(void)
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
/* $Source$ */
|
||||
/* $Revision$ */
|
||||
/* $Date$ */
|
||||
|
12
demo/test.c
12
demo/test.c
@ -1,6 +1,3 @@
|
||||
/* TomsFastMath, a fast ISO C bignum library. -- Tom St Denis */
|
||||
/* SPDX-License-Identifier: Unlicense */
|
||||
|
||||
/* TFM demo program */
|
||||
#include <tfm.h>
|
||||
#include <time.h>
|
||||
@ -430,11 +427,14 @@ draw(&a);draw(&b);draw(&c);draw(&d);
|
||||
printf("d == %lu\n", ix);
|
||||
return 0;
|
||||
}
|
||||
} else if (!strcmp(cmd, "exit")) {
|
||||
printf("\nokay, exiting now\n");
|
||||
return 0;
|
||||
}
|
||||
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
|
||||
/* $Source$ */
|
||||
/* $Revision$ */
|
||||
/* $Date$ */
|
||||
|
@ -1,8 +1,4 @@
|
||||
/* TomsFastMath, a fast ISO C bignum library. -- Tom St Denis */
|
||||
/* SPDX-License-Identifier: Unlicense */
|
||||
|
||||
/* TFM timing analysis */
|
||||
#define _GNU_SOURCE
|
||||
#include <tfm.h>
|
||||
#include <time.h>
|
||||
#include <unistd.h>
|
||||
@ -69,11 +65,21 @@ static void print_line(ulong64 b, ulong64 t)
|
||||
printf("%llu;%s;%llu;%llu\n", ticks, p_str, b, t);
|
||||
}
|
||||
|
||||
static void Addition(ulong64 t1)
|
||||
int main(void)
|
||||
{
|
||||
fp_int a,b,c;
|
||||
ulong64 t2;
|
||||
fp_int a,b,c,d;
|
||||
ulong64 t1, t2;
|
||||
fp_digit fp;
|
||||
unsigned long t, ix;
|
||||
|
||||
t1 = TIMFUNC();
|
||||
sleep(1);
|
||||
ticks = TIMFUNC() - t1;
|
||||
fprintf(stderr, "Ticks per second: %llu\n", ticks);
|
||||
|
||||
printf("Ticks/sec;Algorithm;bits;time\n");
|
||||
/* do some timings... */
|
||||
print_start("Addition");
|
||||
for (t = 2; t <= FP_SIZE / 2; t += 2) {
|
||||
fp_zero(&a);
|
||||
fp_zero(&b);
|
||||
@ -103,13 +109,7 @@ static void Addition(ulong64 t1)
|
||||
}
|
||||
print_line(t * DIGIT_BIT, t2);
|
||||
}
|
||||
}
|
||||
|
||||
static void Multiplication(ulong64 t1)
|
||||
{
|
||||
fp_int a,b,c;
|
||||
ulong64 t2;
|
||||
unsigned long t, ix;
|
||||
print_start("Multiplication");
|
||||
for (t = 2; t < FP_SIZE / 2; t += 2) {
|
||||
fp_zero(&a);
|
||||
fp_zero(&b);
|
||||
@ -259,13 +259,8 @@ static void Multiplication(ulong64 t1)
|
||||
}
|
||||
print_line(t * DIGIT_BIT, t2);
|
||||
}
|
||||
}
|
||||
|
||||
static void Squaring(ulong64 t1)
|
||||
{
|
||||
fp_int a,b;
|
||||
ulong64 t2;
|
||||
unsigned long t, ix;
|
||||
print_start("Squaring");
|
||||
for (t = 2; t < FP_SIZE / 2; t += 2) {
|
||||
fp_zero(&a);
|
||||
fp_zero(&b);
|
||||
@ -412,13 +407,8 @@ static void Squaring(ulong64 t1)
|
||||
}
|
||||
print_line(t * DIGIT_BIT, t2);
|
||||
}
|
||||
}
|
||||
|
||||
static void Invmod(ulong64 t1)
|
||||
{
|
||||
fp_int a,b,c;
|
||||
ulong64 t2;
|
||||
unsigned long t, ix;
|
||||
print_start("Invmod");
|
||||
for (t = 2; t < FP_SIZE / 2; t += 2) {
|
||||
fp_zero(&a);
|
||||
for (ix = 0; ix < t; ix++) {
|
||||
@ -507,14 +497,8 @@ static void Invmod(ulong64 t1)
|
||||
}
|
||||
print_line(t * DIGIT_BIT, t2);
|
||||
}
|
||||
}
|
||||
|
||||
static void Montgomery(ulong64 t1)
|
||||
{
|
||||
fp_int a,b,c,d;
|
||||
ulong64 t2;
|
||||
fp_digit fp;
|
||||
unsigned long t, ix;
|
||||
print_start("Montgomery");
|
||||
for (t = 2; t <= (FP_SIZE / 2) - 4; t += 2) {
|
||||
// printf("%5lu-bit: %9llu\n", t * DIGIT_BIT, t2);
|
||||
fp_zero(&a);
|
||||
@ -606,13 +590,9 @@ static void Montgomery(ulong64 t1)
|
||||
}
|
||||
print_line(t * DIGIT_BIT, t2);
|
||||
}
|
||||
}
|
||||
|
||||
static void Exptmod(ulong64 t1)
|
||||
{
|
||||
fp_int a,b,c,d;
|
||||
ulong64 t2;
|
||||
unsigned long t, ix;
|
||||
print_start("Exptmod");
|
||||
|
||||
for (t = 512 / DIGIT_BIT; t <= (FP_SIZE / 2) - 2; t += 256 / DIGIT_BIT) {
|
||||
fp_zero(&a);
|
||||
fp_zero(&b);
|
||||
@ -641,41 +621,5 @@ static void Exptmod(ulong64 t1)
|
||||
}
|
||||
print_line(t * DIGIT_BIT, t2);
|
||||
}
|
||||
}
|
||||
|
||||
#define FN(n) { n, #n }
|
||||
struct {
|
||||
void (*fn)(ulong64 t1);
|
||||
const char* name;
|
||||
} funcs[] = {
|
||||
FN(Addition),
|
||||
FN(Multiplication),
|
||||
FN(Squaring),
|
||||
FN(Invmod),
|
||||
FN(Montgomery),
|
||||
FN(Exptmod),
|
||||
};
|
||||
|
||||
int main(int argc, char **argv)
|
||||
{
|
||||
ulong64 t1;
|
||||
unsigned int t;
|
||||
char* arg = NULL;
|
||||
|
||||
if (argc > 1) arg = argv[1];
|
||||
|
||||
t1 = TIMFUNC();
|
||||
sleep(1);
|
||||
ticks = TIMFUNC() - t1;
|
||||
fprintf(stderr, "Ticks per second: %llu\n", ticks);
|
||||
|
||||
printf("Ticks/sec;Algorithm;bits;time\n");
|
||||
/* do some timings... */
|
||||
for (t = 0; t < sizeof(funcs)/sizeof(funcs[0]); ++t) {
|
||||
if(arg != NULL && strcasestr(funcs[t].name, arg) == NULL) continue;
|
||||
print_start(funcs[t].name);
|
||||
funcs[t].fn(t1);
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
36
doc/makefile
36
doc/makefile
@ -1,36 +0,0 @@
|
||||
# TomsFastMath, a fast ISO C bignum library. -- Tom St Denis
|
||||
# SPDX-License-Identifier: Unlicense
|
||||
|
||||
ifeq ($V,1)
|
||||
silent=
|
||||
silent_stdout=
|
||||
else
|
||||
silent=@
|
||||
silent_stdout= > /dev/null
|
||||
endif
|
||||
|
||||
all: tfm.pdf
|
||||
|
||||
docdvi: tfm.tex
|
||||
cp tfm.tex tfm.bak
|
||||
touch -r tfm.tex tfm.bak
|
||||
(printf "%s" "\def\fixedpdfdate{"; date +'D:%Y%m%d%H%M%S%:z' -d @$$(stat --format=%Y tfm.tex) | sed "s/:\([0-9][0-9]\)$$/'\1'}/g") > tfm-deterministic.tex
|
||||
printf "%s\n" "\pdfinfo{" >> tfm-deterministic.tex
|
||||
printf "%s\n" " /CreationDate (\fixedpdfdate)" >> tfm-deterministic.tex
|
||||
printf "%s\n}\n" " /ModDate (\fixedpdfdate)" >> tfm-deterministic.tex
|
||||
cat tfm.tex >> tfm-deterministic.tex
|
||||
mv tfm-deterministic.tex tfm.tex
|
||||
touch -r tfm.bak tfm.tex
|
||||
touch tfm.ind
|
||||
latex tfm $(silent_stdout)
|
||||
latex tfm $(silent_stdout)
|
||||
makeindex tfm
|
||||
latex tfm $(silent_stdout)
|
||||
|
||||
tfm.pdf: docdvi
|
||||
latex tfm $(silent_stdout)
|
||||
pdflatex tfm $(silent_stdout)
|
||||
sed -b -i 's,^/ID \[.*\]$$,/ID [<0> <0>],g' tfm.pdf
|
||||
mv tfm.bak tfm.tex
|
||||
|
||||
docs: tfm.pdf
|
BIN
doc/tfm.pdf
Normal file
BIN
doc/tfm.pdf
Normal file
Binary file not shown.
@ -1,8 +1,6 @@
|
||||
#!/usr/bin/perl
|
||||
#
|
||||
|
||||
# we want to filter every between START_INS and END_INS out and then insert crap from another file (this is fun)
|
||||
#
|
||||
# SPDX-License-Identifier: Unlicense
|
||||
|
||||
$dst = shift;
|
||||
$ins = shift;
|
||||
|
2
gen.pl
2
gen.pl
@ -3,11 +3,9 @@
|
||||
# Generates a "single file" you can use to quickly
|
||||
# add the whole source without any makefile troubles
|
||||
#
|
||||
# SPDX-License-Identifier: Unlicense
|
||||
use strict;
|
||||
|
||||
open( OUT, ">mpi.c" ) or die "Couldn't open mpi.c for writing: $!";
|
||||
print OUT "#define TFM_PRE_GEN_MPI_C\n";
|
||||
foreach my $filename (glob "src/*/*fp_*.c") {
|
||||
next if ($filename eq "fp_sqr_comba_generic.c");
|
||||
open( SRC, "<$filename" ) or die "Couldn't open $filename for reading: $!";
|
||||
|
@ -1,6 +1,9 @@
|
||||
#!/bin/bash
|
||||
# SPDX-License-Identifier: Unlicense
|
||||
export a=`find . -type f | sort | grep "[.]/src" | grep "[.]c" | grep -v generators | sed -e 'sE\./EE' | sed -e 's/\.c/\.o/' | xargs`
|
||||
perl ./parsenames.pl OBJECTS "$a"
|
||||
export a=`find . -type f | grep [.]/src | grep [.]h | sed -e 'se\./ee' | xargs`
|
||||
perl ./parsenames.pl HEADERS "$a"
|
||||
|
||||
# $Source: /cvs/libtom/tomsfastmath/genlist.sh,v $
|
||||
# $Revision: 1.1 $
|
||||
# $Date: 2006/12/31 21:31:40 $
|
||||
|
@ -16,7 +16,6 @@ fp_gcd
|
||||
fp_ident
|
||||
fp_invmod
|
||||
fp_isprime
|
||||
fp_isprime_ex
|
||||
fp_lcm
|
||||
fp_lshd
|
||||
fp_mod
|
||||
|
202
makefile
202
makefile
@ -1,15 +1,25 @@
|
||||
# makefile for TomsFastMath, a fast ISO C bignum library. -- Tom St Denis
|
||||
# SPDX-License-Identifier: Unlicense
|
||||
#makefile for TomsFastMath
|
||||
#
|
||||
#
|
||||
VERSION=0.13.1
|
||||
|
||||
ifndef LIBNAME
|
||||
LIBNAME=libtfm.a
|
||||
CFLAGS += -Wall -W -Wshadow -Isrc/headers
|
||||
|
||||
# Compiler and Linker Names
|
||||
ifndef PREFIX
|
||||
PREFIX=
|
||||
endif
|
||||
|
||||
INSTALL_CMD = install
|
||||
UNINSTALL_CMD = rm
|
||||
ifeq ($(CC),cc)
|
||||
CC = $(PREFIX)gcc
|
||||
endif
|
||||
LD=$(PREFIX)ld
|
||||
AR=$(PREFIX)ar
|
||||
RANLIB=$(PREFIX)ranlib
|
||||
|
||||
|
||||
include makefile_include.mk
|
||||
ifndef MAKE
|
||||
MAKE=make
|
||||
endif
|
||||
|
||||
ifeq ($V,1)
|
||||
silent=
|
||||
@ -17,19 +27,30 @@ else
|
||||
silent=@
|
||||
endif
|
||||
|
||||
ifeq ($(COVERAGE),1)
|
||||
CFLAGS += -fprofile-arcs -ftest-coverage
|
||||
LDFLAGS += -lgcov
|
||||
LIB_PRE = -Wl,--whole-archive
|
||||
LIB_POST = -Wl,--no-whole-archive
|
||||
endif
|
||||
|
||||
%.o: %.c
|
||||
ifneq ($V,1)
|
||||
@echo " * ${CC} $@"
|
||||
endif
|
||||
${silent} ${CC} ${CFLAGS} -c $< -o $@
|
||||
|
||||
ifdef COMPILE_DEBUG
|
||||
#debug
|
||||
CFLAGS += -g3
|
||||
else
|
||||
ifndef IGNORE_SPEED
|
||||
|
||||
CFLAGS += -O3 -funroll-loops
|
||||
|
||||
#profiling
|
||||
#PROF=-pg -g
|
||||
#CFLAGS += $(PROF)
|
||||
|
||||
#speed
|
||||
CFLAGS += -fomit-frame-pointer
|
||||
|
||||
endif
|
||||
endif
|
||||
|
||||
#START_INS
|
||||
OBJECTS=src/addsub/fp_add.o src/addsub/fp_add_d.o src/addsub/fp_addmod.o src/addsub/fp_cmp.o \
|
||||
src/addsub/fp_cmp_d.o src/addsub/fp_cmp_mag.o src/addsub/fp_sub.o src/addsub/fp_sub_d.o \
|
||||
@ -61,72 +82,143 @@ HEADERS=src/headers/tfm_private.h $(HEADERS_PUB)
|
||||
|
||||
#END_INS
|
||||
|
||||
ifndef LIBPATH
|
||||
LIBPATH=/usr/lib
|
||||
endif
|
||||
|
||||
ifndef INCPATH
|
||||
INCPATH=/usr/include
|
||||
endif
|
||||
|
||||
ifndef INSTALL_GROUP
|
||||
GROUP=wheel
|
||||
else
|
||||
GROUP=$(INSTALL_GROUP)
|
||||
endif
|
||||
|
||||
ifndef INSTALL_USER
|
||||
USER=root
|
||||
else
|
||||
USER=$(INSTALL_USER)
|
||||
endif
|
||||
|
||||
ifndef LIBNAME
|
||||
LIBNAME=libtfm.a
|
||||
endif
|
||||
|
||||
default: $(LIBNAME)
|
||||
|
||||
$(OBJECTS): $(HEADERS)
|
||||
|
||||
$(LIBNAME): $(OBJECTS)
|
||||
$(AR) $(ARFLAGS) $@ $(OBJECTS)
|
||||
$(RANLIB) $@
|
||||
|
||||
install: .common_install
|
||||
install: $(LIBNAME)
|
||||
install -d -g $(GROUP) -o $(USER) $(DESTDIR)$(LIBPATH)
|
||||
install -d -g $(GROUP) -o $(USER) $(DESTDIR)$(INCPATH)
|
||||
install -g $(GROUP) -o $(USER) $(LIBNAME) $(DESTDIR)$(LIBPATH)
|
||||
install -g $(GROUP) -o $(USER) $(HEADERS_PUB) $(DESTDIR)$(INCPATH)
|
||||
|
||||
uninstall: .common_uninstall
|
||||
HEADER_FILES=$(notdir $(HEADERS_PUB))
|
||||
uninstall:
|
||||
rm $(DESTDIR)$(LIBPATH)/$(LIBNAME)
|
||||
rm $(HEADER_FILES:%=$(DESTDIR)$(INCPATH)/%)
|
||||
|
||||
.PHONY: mtest
|
||||
mtest: $(LIBNAME)
|
||||
cd mtest; CC="$(CC)" CFLAGS="$(CFLAGS) -I../" MAKE=${MAKE} ${MAKE} mtest
|
||||
|
||||
demo/test.o: CFLAGS+=-Wno-unused-result
|
||||
|
||||
.PHONY: test
|
||||
test: $(LIBNAME) demo/test.o
|
||||
$(CC) $(CFLAGS) demo/test.o $(LIB_PRE) $(LIBNAME) $(LIB_POST) $(PROF) -o test
|
||||
$(CC) $(CFLAGS) demo/test.o $(LIBNAME) $(PROF) -o test
|
||||
|
||||
test_standalone: CFLAGS+=-DTFM_DEMO_TEST_VS_MTEST=0
|
||||
|
||||
.PHONY: test_standalone
|
||||
test_standalone: $(LIBNAME) demo/test.o
|
||||
$(CC) $(CFLAGS) demo/test.o $(LIB_PRE) $(LIBNAME) $(LIB_POST) $(PROF) -o test
|
||||
|
||||
testme: test mtest
|
||||
./mtest/mtest -15 | ./test
|
||||
$(CC) $(CFLAGS) demo/test.o $(LIBNAME) $(PROF) -o test
|
||||
|
||||
timing: $(LIBNAME) demo/timing.o
|
||||
$(CC) $(CFLAGS) demo/timing.o $(LIBNAME) $(PROF) -o timing
|
||||
|
||||
profiled:
|
||||
CC="$(CC)" CROSS_COMPILE="${CROSS_COMPILE} CFLAGS="${CFLAGS} -fprofile-generate" MAKE=${MAKE} ${MAKE} timing
|
||||
CC="$(CC)" PREFIX="${PREFIX} CFLAGS="${CFLAGS} -fprofile-generate" MAKE=${MAKE} ${MAKE} timing
|
||||
./test
|
||||
rm -f `find . -type f -name "*.o" | xargs`
|
||||
rm -f `find . -type f -name "*.a" | xargs`
|
||||
rm -f test
|
||||
CC=$(CC) CROSS_COMPILE="${CROSS_COMPILE} CFLAGS="${CFLAGS} -fprofile-use" MAKE=${MAKE} ${MAKE} timing
|
||||
|
||||
# target that pre-processes all coverage data
|
||||
lcov-single-create:
|
||||
lcov --capture --no-external --directory src -q --output-file coverage_std.info
|
||||
|
||||
# target that removes all coverage output
|
||||
cleancov-clean:
|
||||
rm -f `find . -type f -name "*.info" | xargs`
|
||||
rm -rf coverage/
|
||||
|
||||
# generates html output from all coverage_*.info files
|
||||
lcov:
|
||||
lcov `find -name 'coverage_*.info' -exec echo -n " -a {}" \;` -o coverage.info -q 2>/dev/null
|
||||
genhtml coverage.info --output-directory coverage -q
|
||||
|
||||
# combines all necessary steps to create the coverage from a single testrun with e.g.
|
||||
lcov-single:
|
||||
$(MAKE) cleancov-clean
|
||||
$(MAKE) lcov-single-create
|
||||
$(MAKE) lcov
|
||||
|
||||
|
||||
#make the code coverage of the library
|
||||
coverage: CFLAGS += -fprofile-arcs -ftest-coverage
|
||||
coverage: LDFLAGS += -lgcov
|
||||
coverage: LIB_PRE = -Wl,--whole-archive
|
||||
coverage: LIB_POST = -Wl,--no-whole-archive
|
||||
|
||||
coverage: testme
|
||||
$(MAKE) lcov-single
|
||||
|
||||
CC=$(CC) PREFIX="${PREFIX} CFLAGS="${CFLAGS} -fprofile-use" MAKE=${MAKE} ${MAKE} timing
|
||||
|
||||
stest: $(LIBNAME) demo/stest.o
|
||||
$(CC) $(CFLAGS) demo/stest.o $(LIBNAME) -o stest
|
||||
|
||||
rsatest: $(LIBNAME) demo/rsa.o
|
||||
$(CC) $(CFLAGS) demo/rsa.o $(LIBNAME) -o rsatest
|
||||
|
||||
docdvi: tfm.tex
|
||||
cp tfm.tex tfm.bak
|
||||
touch --reference=tfm.tex tfm.bak
|
||||
(printf "%s" "\def\fixedpdfdate{"; date +'D:%Y%m%d%H%M%S%:z' -d @$$(stat --format=%Y tfm.tex) | sed "s/:\([0-9][0-9]\)$$/'\1'}/g") > tfm-deterministic.tex
|
||||
printf "%s\n" "\pdfinfo{" >> tfm-deterministic.tex
|
||||
printf "%s\n" " /CreationDate (\fixedpdfdate)" >> tfm-deterministic.tex
|
||||
printf "%s\n}\n" " /ModDate (\fixedpdfdate)" >> tfm-deterministic.tex
|
||||
cat tfm.tex >> tfm-deterministic.tex
|
||||
mv tfm-deterministic.tex tfm.tex
|
||||
touch --reference=tfm.bak tfm.tex
|
||||
touch tfm.ind
|
||||
latex tfm >/dev/null
|
||||
latex tfm >/dev/null
|
||||
makeindex tfm
|
||||
latex tfm >/dev/null
|
||||
|
||||
docs: docdvi
|
||||
latex tfm >/dev/null
|
||||
pdflatex tfm >/dev/null
|
||||
sed -b -i 's,^/ID \[.*\]$$,/ID [<0> <0>],g' tfm.pdf
|
||||
mv tfm.bak tfm.tex
|
||||
mv -f tfm.pdf doc
|
||||
|
||||
#This rule cleans the source tree of all compiled code, not including the pdf
|
||||
#documentation.
|
||||
clean:
|
||||
rm -f `find . -type f -name "*.o" | xargs`
|
||||
rm -f `find . -type f -name "*.lo" | xargs`
|
||||
rm -f `find . -type f -name "*.a" | xargs`
|
||||
rm -f `find . -type f -name "*.la" | xargs`
|
||||
rm -f `find . -type f -name "*.obj" | xargs`
|
||||
rm -f `find . -type f -name "*.lib" | xargs`
|
||||
rm -f `find . -type f -name "*.exe" | xargs`
|
||||
rm -f `find . -type f -name "*.gcov" | xargs`
|
||||
rm -f `find . -type f -name "*.gcda" | xargs`
|
||||
rm -f `find . -type f -name "*.gcno" | xargs`
|
||||
rm -f `find . -type f -name "*.il" | xargs`
|
||||
rm -f `find . -type f -name "*.dyn" | xargs`
|
||||
rm -f `find . -type f -name "*.dpi" | xargs`
|
||||
rm -rf `find . -type d -name "*.libs" | xargs`
|
||||
rm -f tfm.aux tfm.dvi tfm.idx tfm.ilg tfm.ind tfm.lof tfm.log tfm.out tfm.toc test test.exe
|
||||
cd mtest; MAKE=${MAKE} ${MAKE} clean
|
||||
|
||||
.PHONY: pre_gen
|
||||
pre_gen:
|
||||
perl gen.pl
|
||||
sed -e 's/[[:blank:]]*$$//' mpi.c > pre_gen/mpi.c
|
||||
rm mpi.c
|
||||
|
||||
zipup:
|
||||
rm -rf ../tomsfastmath-$(VERSION) && rm -f ../tfm-$(VERSION).zip ../tfm-$(VERSION).tar.bz2 && \
|
||||
expsrc.sh -i . -o ../tomsfastmath-$(VERSION) --svntags --no-fetch -p '*.c' -p '*.h' && \
|
||||
MAKE=${MAKE} ${MAKE} -C ../tomsfastmath-$(VERSION) docs && \
|
||||
tar -c ../tomsfastmath-$(VERSION)/* | xz -cz > ../tfm-$(VERSION).tar.xz && \
|
||||
find ../tomsfastmath-$(VERSION)/ -type f -exec unix2dos -q {} \; && \
|
||||
zip -9 -r ../tfm-$(VERSION).zip ../tomsfastmath-$(VERSION)/* && \
|
||||
gpg -b -a ../tfm-$(VERSION).tar.xz && gpg -b -a ../tfm-$(VERSION).zip
|
||||
|
||||
new_file:
|
||||
bash updatemakes.sh
|
||||
|
||||
# $Source$
|
||||
# $Revision$
|
||||
# $Date$
|
||||
|
@ -1,18 +1,25 @@
|
||||
# makefile for TomsFastMath, a fast ISO C bignum library. -- Tom St Denis
|
||||
# SPDX-License-Identifier: Unlicense
|
||||
|
||||
ifndef LIBNAME
|
||||
LIBNAME=libtfm.la
|
||||
endif
|
||||
#makefile for TomsFastMath
|
||||
#
|
||||
#
|
||||
VERSION=1:0:0
|
||||
|
||||
LT ?= libtool
|
||||
LTCOMPILE = $(LT) --mode=compile --tag=CC $(CC)
|
||||
|
||||
INSTALL_CMD = $(LT) --mode=install install
|
||||
UNINSTALL_CMD = $(LT) --mode=uninstall rm
|
||||
CFLAGS += -Wall -W -Wshadow -Isrc/headers
|
||||
|
||||
ifndef IGNORE_SPEED
|
||||
|
||||
include makefile_include.mk
|
||||
CFLAGS += -O3 -funroll-all-loops
|
||||
|
||||
#profiling
|
||||
#PROF=-pg -g
|
||||
#CFLAGS += $(PROF)
|
||||
|
||||
#speed
|
||||
CFLAGS += -fomit-frame-pointer
|
||||
|
||||
endif
|
||||
|
||||
#START_INS
|
||||
OBJECTS=src/addsub/fp_add.o src/addsub/fp_add_d.o src/addsub/fp_addmod.o src/addsub/fp_cmp.o \
|
||||
@ -40,29 +47,65 @@ src/sqr/fp_sqr_comba_48.o src/sqr/fp_sqr_comba_4.o src/sqr/fp_sqr_comba_64.o src
|
||||
src/sqr/fp_sqr_comba_7.o src/sqr/fp_sqr_comba_8.o src/sqr/fp_sqr_comba_9.o src/sqr/fp_sqr_comba.o \
|
||||
src/sqr/fp_sqr_comba_generic.o src/sqr/fp_sqr_comba_small_set.o src/sqr/fp_sqrmod.o
|
||||
|
||||
LOBJECTS = $(OBJECTS:.o=.lo)
|
||||
|
||||
HEADERS_PUB:=src/headers/tfm.h
|
||||
HEADERS=src/headers/tfm_private.h $(HEADERS_PUB)
|
||||
|
||||
#END_INS
|
||||
|
||||
|
||||
ifndef LIBPATH
|
||||
LIBPATH=/usr/lib
|
||||
endif
|
||||
|
||||
ifndef INCPATH
|
||||
INCPATH=/usr/include
|
||||
endif
|
||||
|
||||
ifndef INSTALL_GROUP
|
||||
GROUP=wheel
|
||||
else
|
||||
GROUP=$(INSTALL_GROUP)
|
||||
endif
|
||||
|
||||
ifndef INSTALL_USER
|
||||
USER=root
|
||||
else
|
||||
USER=$(INSTALL_USER)
|
||||
endif
|
||||
|
||||
ifndef LIBNAME
|
||||
LIBNAME=libtfm.la
|
||||
endif
|
||||
|
||||
ifndef LIBNAME_S
|
||||
LIBNAME_S=libtfm.a
|
||||
endif
|
||||
|
||||
default: $(LIBNAME)
|
||||
|
||||
$(OBJECTS): $(HEADERS)
|
||||
|
||||
.c.o:
|
||||
$(LTCOMPILE) $(CFLAGS) $(LDFLAGS) -o $@ -c $<
|
||||
|
||||
$(LIBNAME): $(OBJECTS)
|
||||
$(LT) --mode=link --tag=CC $(CC) $(CFLAGS) $(LDFLAGS) $(LOBJECTS) -o $(LIBNAME) -rpath $(LIBPATH) -version-info $(VERSION_LIB) -export-symbols libtfm.symbols
|
||||
libtool --mode=link --tag=CC $(CC) $(CFLAGS) $(LDFLAGS) `find . -type f | LC_ALL=C sort | grep "[.]lo" | xargs` -o $(LIBNAME) -rpath $(LIBPATH) -version-info $(VERSION) -export-symbols libtfm.symbols
|
||||
|
||||
install: .common_install
|
||||
sed -e 's,^Version:.*,Version: $(VERSION_PC),' tomsfastmath.pc.in > tomsfastmath.pc
|
||||
install -d $(DESTDIR)$(LIBPATH)/pkgconfig
|
||||
install -m 644 tomsfastmath.pc $(DESTDIR)$(LIBPATH)/pkgconfig/
|
||||
install: $(LIBNAME)
|
||||
install -d -g $(GROUP) -o $(USER) $(DESTDIR)$(LIBPATH)
|
||||
libtool --mode=install install -c $(LIBNAME) $(DESTDIR)$(LIBPATH)/$(LIBNAME)
|
||||
install -d -g $(GROUP) -o $(USER) $(DESTDIR)$(INCPATH)
|
||||
install -g $(GROUP) -o $(USER) $(HEADERS_PUB) $(DESTDIR)$(INCPATH)
|
||||
|
||||
uninstall: .common_uninstall
|
||||
rm $(DESTDIR)$(LIBPATH)/pkgconfig/tomsfastmath.pc
|
||||
HEADER_FILES=$(notdir $(HEADERS_PUB))
|
||||
uninstall:
|
||||
libtool --mode=uninstall rm $(DESTDIR)$(LIBPATH)/$(LIBNAME)
|
||||
rm $(HEADER_FILES:%=$(DESTDIR)$(INCPATH)/%)
|
||||
|
||||
mtest/mtest: mtest/mtest.c
|
||||
cd mtest ; make mtest
|
||||
|
||||
demo/test.o: CFLAGS+=-Wno-unused-result
|
||||
|
||||
.PHONY: test
|
||||
test: $(LIBNAME) demo/test.o
|
||||
@ -80,3 +123,8 @@ stest: $(LIBNAME) demo/stest.o
|
||||
.PHONY: timing
|
||||
timing: $(LIBNAME) demo/timing.o
|
||||
$(LT) --mode=link --tag=CC $(CC) $(CFLAGS) $(CPPFLAGS) $(LDFLAGS) -o timing demo/timing.o $(LIBNAME)
|
||||
|
||||
# $Source$
|
||||
# $Revision$
|
||||
# $Date$
|
||||
|
||||
|
@ -1,165 +0,0 @@
|
||||
#
|
||||
# Include makefile used by makefile + makefile.shared
|
||||
# (GNU make only)
|
||||
# SPDX-License-Identifier: Unlicense
|
||||
|
||||
ifndef INSTALL_CMD
|
||||
$(error your makefile must define INSTALL_CMD)
|
||||
endif
|
||||
ifndef UNINSTALL_CMD
|
||||
$(error your makefile must define UNINSTALL_CMD)
|
||||
endif
|
||||
|
||||
#
|
||||
# The Version of the library
|
||||
#
|
||||
VERSION=0.13.1-next
|
||||
VERSION_LIB=1:0:0
|
||||
VERSION_PC=0.13.1
|
||||
|
||||
GIT_VERSION := $(shell [ -e .git ] && { printf git- ; git describe --tags --always --dirty ; } || echo $(VERSION))
|
||||
ifneq ($(GIT_VERSION),)
|
||||
CFLAGS += -DGIT_VERSION=\"$(GIT_VERSION)\"
|
||||
endif
|
||||
|
||||
# Compiler and Linker Names
|
||||
ifndef CROSS_COMPILE
|
||||
CROSS_COMPILE:=
|
||||
endif
|
||||
|
||||
ifeq ($(CC),cc)
|
||||
CC := $(CROSS_COMPILE)gcc
|
||||
endif
|
||||
LD:=$(CROSS_COMPILE)ld
|
||||
AR:=$(CROSS_COMPILE)ar
|
||||
RANLIB=$(CROSS_COMPILE)ranlib
|
||||
|
||||
ifndef MAKE
|
||||
MAKE=make
|
||||
endif
|
||||
|
||||
#
|
||||
# Compilation flags
|
||||
#
|
||||
# Note that we're extending the environments' CFLAGS.
|
||||
# If you think that our CFLAGS are not nice you can easily override them
|
||||
# by giving them as a parameter to make:
|
||||
# make CFLAGS="-I./src/headers/ -DLTC_SOURCE ..." ...
|
||||
#
|
||||
|
||||
CFLAGS += -Wall -W -Wshadow -Isrc/headers
|
||||
|
||||
ifdef COMPILE_DEBUG
|
||||
#debug
|
||||
CFLAGS += -g3
|
||||
else
|
||||
ifndef IGNORE_SPEED
|
||||
|
||||
CFLAGS += -O3
|
||||
|
||||
PLATFORM := $(shell uname | sed -e 's/_.*//')
|
||||
ifneq ($(PLATFORM), Darwin)
|
||||
CFLAGS += -funroll-loops
|
||||
endif
|
||||
|
||||
#profiling
|
||||
#PROF=-pg -g
|
||||
#CFLAGS += $(PROF)
|
||||
|
||||
#speed
|
||||
CFLAGS += -fomit-frame-pointer
|
||||
|
||||
endif
|
||||
endif
|
||||
|
||||
#
|
||||
# (Un)Install related variables
|
||||
#
|
||||
DESTDIR ?=
|
||||
PREFIX ?= /usr/local
|
||||
LIBPATH ?= $(PREFIX)/lib
|
||||
INCPATH ?= $(PREFIX)/include
|
||||
|
||||
|
||||
#
|
||||
# Build targets
|
||||
#
|
||||
|
||||
default: $(LIBNAME)
|
||||
|
||||
|
||||
demo/test.o: CFLAGS+=-Wno-unused-result
|
||||
|
||||
.PHONY: mtest
|
||||
mtest: $(LIBNAME)
|
||||
CC="$(CC)" CFLAGS="$(CFLAGS) -I../" MAKE=${MAKE} ${MAKE} -C mtest/ mtest
|
||||
|
||||
.common_install: $(LIBNAME)
|
||||
install -d $(DESTDIR)$(LIBPATH)
|
||||
$(INSTALL_CMD) $(LIBNAME) $(DESTDIR)$(LIBPATH)/$(LIBNAME)
|
||||
install -d $(DESTDIR)$(INCPATH)
|
||||
install $(HEADERS_PUB) $(DESTDIR)$(INCPATH)
|
||||
|
||||
|
||||
HEADER_FILES=$(notdir $(HEADERS_PUB))
|
||||
.common_uninstall:
|
||||
$(UNINSTALL_CMD) $(DESTDIR)$(LIBPATH)/$(LIBNAME)
|
||||
rm $(HEADER_FILES:%=$(DESTDIR)$(INCPATH)/%)
|
||||
|
||||
|
||||
#This rule cleans the source tree of all compiled code, not including the pdf
|
||||
#documentation.
|
||||
clean:
|
||||
find . -type f -name "*.o" \
|
||||
-o -name "*.lo" \
|
||||
-o -name "*.a" \
|
||||
-o -name "*.la" \
|
||||
-o -name "*.obj" \
|
||||
-o -name "*.lib" \
|
||||
-o -name "*.exe" \
|
||||
-o -name "*.dll" \
|
||||
-o -name "*.so" \
|
||||
-o -name "*.gcov"\
|
||||
-o -name "*.gcda"\
|
||||
-o -name "*.gcno"\
|
||||
-o -name "*.il" \
|
||||
-o -name "*.dyn" \
|
||||
-o -name "*.dpi" | xargs rm -f
|
||||
find . -type d -name "*.libs" | xargs rm -rf
|
||||
rm -f tfm.aux tfm.dvi tfm.idx tfm.ilg tfm.ind tfm.lof tfm.log tfm.out tfm.toc test test.exe
|
||||
cd mtest; MAKE=${MAKE} ${MAKE} clean
|
||||
|
||||
docs:
|
||||
$(MAKE) -C doc/ $@ V=$(V)
|
||||
|
||||
doc/tfm.pdf:
|
||||
$(MAKE) -C doc/ tfm.pdf V=$(V)
|
||||
|
||||
pre_gen:
|
||||
mkdir -p pre_gen
|
||||
perl gen.pl
|
||||
sed -e 's/[[:blank:]]*$$//' mpi.c > pre_gen/mpi.c
|
||||
rm mpi.c
|
||||
|
||||
zipup: doc/tfm.pdf
|
||||
@# Update the index, so diff-index won't fail in case the pdf has been created.
|
||||
@# As the pdf creation modifies tfm.tex, git sometimes detects the
|
||||
@# modified file, but misses that it's put back to its original version.
|
||||
@git update-index --refresh
|
||||
@git diff-index --quiet HEAD -- || ( echo "FAILURE: uncommited changes or not a git" && exit 1 )
|
||||
rm -rf tomsfastmath-$(VERSION) tfm-$(VERSION).*
|
||||
@# files/dirs excluded from "git archive" are defined in .gitattributes
|
||||
git archive --format=tar --prefix=tomsfastmath-$(VERSION)/ HEAD | tar x
|
||||
mkdir -p tomsfastmath-$(VERSION)/doc
|
||||
cp doc/tfm.pdf tomsfastmath-$(VERSION)/doc/tfm.pdf
|
||||
$(MAKE) -C tomsfastmath-$(VERSION)/ pre_gen
|
||||
tar -c tomsfastmath-$(VERSION)/ | xz -6e -c - > tfm-$(VERSION).tar.xz
|
||||
zip -9rq tfm-$(VERSION).zip tomsfastmath-$(VERSION)
|
||||
rm -rf tomsfastmath-$(VERSION)
|
||||
gpg -b -a tfm-$(VERSION).tar.xz
|
||||
gpg -b -a tfm-$(VERSION).zip
|
||||
|
||||
new_file:
|
||||
bash updatemakes.sh
|
||||
|
||||
.PHONY: pre_gen doc/tfm.pdf
|
4
mess.sh
Normal file
4
mess.sh
Normal file
@ -0,0 +1,4 @@
|
||||
#!/bin/bash
|
||||
if cvs log $1 >/dev/null 2>/dev/null; then exit 0; else echo "$1 shouldn't be here" ; exit 1; fi
|
||||
|
||||
|
@ -1,6 +1,3 @@
|
||||
# TomsFastMath, a fast ISO C bignum library. -- Tom St Denis
|
||||
# SPDX-License-Identifier: Unlicense
|
||||
|
||||
CFLAGS += -Wall -W -O3 -Wno-unused-result
|
||||
|
||||
default: mtest
|
||||
|
106
mtest/mtest.c
106
mtest/mtest.c
@ -27,7 +27,6 @@ mulmod
|
||||
1
|
||||
|
||||
*/
|
||||
/* SPDX-License-Identifier: Unlicense */
|
||||
|
||||
#ifdef MP_8BIT
|
||||
#define THE_MASK 127
|
||||
@ -39,70 +38,42 @@ mulmod
|
||||
#include <stdlib.h>
|
||||
#include <time.h>
|
||||
#include <tommath.h>
|
||||
#define CRYPT
|
||||
#undef DIGIT_BIT
|
||||
#include "../src/headers/tfm.h"
|
||||
|
||||
#ifdef TFM_MTEST_REAL_RAND
|
||||
#define getRandChar() fgetc(rng)
|
||||
FILE *rng;
|
||||
#else
|
||||
#define getRandChar() (rand()&0xFF)
|
||||
#endif
|
||||
|
||||
/* 1-2048 bit numbers */
|
||||
void rand_num(mp_int *a)
|
||||
{
|
||||
int size;
|
||||
unsigned char buf[2048];
|
||||
size_t sz;
|
||||
unsigned char buf[(FP_MAX_SIZE/16 - DIGIT_BIT/2) + 1];
|
||||
|
||||
size = 1 + ((getRandChar()<<8) + getRandChar()) % 101;
|
||||
buf[0] = (getRandChar()&1)?1:0;
|
||||
#ifdef TFM_MTEST_REAL_RAND
|
||||
sz = fread(buf+1, 1, size, rng);
|
||||
#else
|
||||
sz = 1;
|
||||
while (sz < (unsigned)size) {
|
||||
buf[sz] = getRandChar();
|
||||
++sz;
|
||||
}
|
||||
#endif
|
||||
if (sz != (unsigned)size) {
|
||||
fprintf(stderr, "\nWarning: fread failed\n\n");
|
||||
}
|
||||
while (buf[1] == 0) buf[1] = getRandChar();
|
||||
size = 1 + ((fgetc(rng)<<8) + fgetc(rng)) % (FP_MAX_SIZE/16 - DIGIT_BIT/2);
|
||||
buf[0] = (fgetc(rng)&1)?1:0;
|
||||
fread(buf+1, 1, size, rng);
|
||||
while (buf[1] == 0) buf[1] = fgetc(rng);
|
||||
mp_read_raw(a, buf, 1+size);
|
||||
}
|
||||
|
||||
/* 1-256 bit numbers (to test things like exptmod) */
|
||||
void rand_num2(mp_int *a)
|
||||
{
|
||||
int size;
|
||||
unsigned char buf[2048];
|
||||
size_t sz;
|
||||
unsigned char buf[(FP_MAX_SIZE/16 - DIGIT_BIT/2) + 1];
|
||||
|
||||
size = 10 + ((getRandChar()<<8) + getRandChar()) % 101;
|
||||
buf[0] = (getRandChar()&1)?1:0;
|
||||
#ifdef TFM_MTEST_REAL_RAND
|
||||
sz = fread(buf+1, 1, size, rng);
|
||||
#else
|
||||
sz = 1;
|
||||
while (sz < (unsigned)size) {
|
||||
buf[sz] = getRandChar();
|
||||
++sz;
|
||||
}
|
||||
#endif
|
||||
if (sz != (unsigned)size) {
|
||||
fprintf(stderr, "\nWarning: fread failed\n\n");
|
||||
}
|
||||
while (buf[1] == 0) buf[1] = getRandChar();
|
||||
size = 1 + ((fgetc(rng)<<8) + fgetc(rng)) % (FP_MAX_SIZE/16 - DIGIT_BIT/2);
|
||||
buf[0] = (fgetc(rng)&1)?1:0;
|
||||
fread(buf+1, 1, size, rng);
|
||||
while (buf[1] == 0) buf[1] = fgetc(rng);
|
||||
mp_read_raw(a, buf, 1+size);
|
||||
}
|
||||
|
||||
|
||||
#define mp_to64(a, b) mp_toradix_n(a, b, 64, sizeof(b))
|
||||
|
||||
int main(int argc, char *argv[])
|
||||
int main(void)
|
||||
{
|
||||
long long max;
|
||||
int n, tmp;
|
||||
mp_int a, b, c, d, e;
|
||||
#ifdef MTEST_NO_FULLSPEED
|
||||
@ -117,27 +88,6 @@ int main(int argc, char *argv[])
|
||||
mp_init(&e);
|
||||
|
||||
|
||||
if (argc > 1) {
|
||||
max = strtol(argv[1], NULL, 0);
|
||||
printf("%lld\n", max);
|
||||
if (max < 0) {
|
||||
max = -max;
|
||||
printf("%lld\n", max);
|
||||
if (max < 64) {
|
||||
unsigned long long m = (1ULL << (max)) + 1;
|
||||
max = (long long)m;
|
||||
} else {
|
||||
max = 1;
|
||||
}
|
||||
printf("%lld\n", max);
|
||||
} else if (max == 0) {
|
||||
max = 1;
|
||||
}
|
||||
}
|
||||
else {
|
||||
max = 0;
|
||||
}
|
||||
|
||||
/* initial (2^n - 1)^2 testing, makes sure the comba multiplier works [it has the new carry code] */
|
||||
/*
|
||||
mp_set(&a, 1);
|
||||
@ -155,7 +105,6 @@ int main(int argc, char *argv[])
|
||||
}
|
||||
*/
|
||||
|
||||
#ifdef TFM_MTEST_REAL_RAND
|
||||
rng = fopen("/dev/urandom", "rb");
|
||||
if (rng == NULL) {
|
||||
rng = fopen("/dev/random", "rb");
|
||||
@ -164,9 +113,6 @@ int main(int argc, char *argv[])
|
||||
rng = stdin;
|
||||
}
|
||||
}
|
||||
#else
|
||||
srand(23);
|
||||
#endif
|
||||
|
||||
#ifdef MTEST_NO_FULLSPEED
|
||||
t1 = clock();
|
||||
@ -178,12 +124,7 @@ int main(int argc, char *argv[])
|
||||
t1 = clock();
|
||||
}
|
||||
#endif
|
||||
n = getRandChar() % 16;
|
||||
if (max != 0) {
|
||||
--max;
|
||||
if (max == 0)
|
||||
n = 255;
|
||||
}
|
||||
n = fgetc(rng) % 16;
|
||||
if (n == 0) {
|
||||
/* add tests */
|
||||
rand_num(&a);
|
||||
@ -247,7 +188,7 @@ int main(int argc, char *argv[])
|
||||
/* mul_2d test */
|
||||
rand_num(&a);
|
||||
mp_copy(&a, &b);
|
||||
n = getRandChar() & 63;
|
||||
n = fgetc(rng) & 63;
|
||||
mp_mul_2d(&b, n, &b);
|
||||
mp_to64(&a, buf);
|
||||
printf("mul2d\n");
|
||||
@ -259,7 +200,7 @@ int main(int argc, char *argv[])
|
||||
/* div_2d test */
|
||||
rand_num(&a);
|
||||
mp_copy(&a, &b);
|
||||
n = getRandChar() & 63;
|
||||
n = fgetc(rng) & 63;
|
||||
mp_div_2d(&b, n, &b, NULL);
|
||||
mp_to64(&a, buf);
|
||||
printf("div2d\n");
|
||||
@ -317,14 +258,14 @@ int main(int argc, char *argv[])
|
||||
printf("%s\n", buf);
|
||||
} else if (n == 10) {
|
||||
/* invmod test */
|
||||
do {
|
||||
rand_num2(&a);
|
||||
rand_num2(&b);
|
||||
b.dp[0] |= 1;
|
||||
b.sign = MP_ZPOS;
|
||||
a.sign = MP_ZPOS;
|
||||
mp_gcd(&a, &b, &c);
|
||||
} while (mp_cmp_d(&c, 1) != 0 || mp_cmp_d(&b, 1) == 0);
|
||||
if (mp_cmp_d(&c, 1) != 0) continue;
|
||||
if (mp_cmp_d(&b, 1) == 0) continue;
|
||||
mp_invmod(&a, &b, &c);
|
||||
printf("invmod\n");
|
||||
mp_to64(&a, buf);
|
||||
@ -377,13 +318,12 @@ int main(int argc, char *argv[])
|
||||
printf("%s\n%d\n", buf, tmp);
|
||||
mp_to64(&b, buf);
|
||||
printf("%s\n", buf);
|
||||
} else if (n == 255) {
|
||||
printf("exit\n");
|
||||
break;
|
||||
}
|
||||
}
|
||||
#ifdef TFM_MTEST_REAL_RAND
|
||||
fclose(rng);
|
||||
#endif
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* $Source$ */
|
||||
/* $Revision$ */
|
||||
/* $Date$ */
|
||||
|
@ -4,7 +4,6 @@
|
||||
# wrapped at 80 chars
|
||||
#
|
||||
# Tom St Denis
|
||||
# SPDX-License-Identifier: Unlicense
|
||||
@a = split(" ", $ARGV[1]);
|
||||
$b = "$ARGV[0]=";
|
||||
$len = length($b);
|
||||
@ -21,3 +20,7 @@ foreach my $obj (@a) {
|
||||
#if ($ARGV[0] eq "HEADERS") { print "testprof/tomcrypt_test.h"; }
|
||||
|
||||
print "\n\n";
|
||||
|
||||
# $Source: /cvs/libtom/tomsfastmath/parsenames.pl,v $
|
||||
# $Revision: 1.1 $
|
||||
# $Date: 2006/12/31 21:31:40 $
|
||||
|
13588
pre_gen/mpi.c
Normal file
13588
pre_gen/mpi.c
Normal file
File diff suppressed because it is too large
Load Diff
@ -1,5 +1,12 @@
|
||||
/* TomsFastMath, a fast ISO C bignum library. -- Tom St Denis */
|
||||
/* SPDX-License-Identifier: Unlicense */
|
||||
/* TomsFastMath, a fast ISO C bignum library.
|
||||
*
|
||||
* This project is meant to fill in where LibTomMath
|
||||
* falls short. That is speed ;-)
|
||||
*
|
||||
* This project is public domain and free for all purposes.
|
||||
*
|
||||
* Tom St Denis, tomstdenis@gmail.com
|
||||
*/
|
||||
#include <tfm_private.h>
|
||||
|
||||
void fp_add(fp_int *a, fp_int *b, fp_int *c)
|
||||
@ -30,3 +37,7 @@ void fp_add(fp_int *a, fp_int *b, fp_int *c)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/* $Source$ */
|
||||
/* $Revision$ */
|
||||
/* $Date$ */
|
||||
|
@ -1,5 +1,12 @@
|
||||
/* TomsFastMath, a fast ISO C bignum library. -- Tom St Denis */
|
||||
/* SPDX-License-Identifier: Unlicense */
|
||||
/* TomsFastMath, a fast ISO C bignum library.
|
||||
*
|
||||
* This project is meant to fill in where LibTomMath
|
||||
* falls short. That is speed ;-)
|
||||
*
|
||||
* This project is public domain and free for all purposes.
|
||||
*
|
||||
* Tom St Denis, tomstdenis@gmail.com
|
||||
*/
|
||||
#include <tfm_private.h>
|
||||
|
||||
/* c = a + b */
|
||||
@ -9,3 +16,7 @@ void fp_add_d(fp_int *a, fp_digit b, fp_int *c)
|
||||
fp_set(&tmp, b);
|
||||
fp_add(a,&tmp,c);
|
||||
}
|
||||
|
||||
/* $Source$ */
|
||||
/* $Revision$ */
|
||||
/* $Date$ */
|
||||
|
@ -1,5 +1,12 @@
|
||||
/* TomsFastMath, a fast ISO C bignum library. -- Tom St Denis */
|
||||
/* SPDX-License-Identifier: Unlicense */
|
||||
/* TomsFastMath, a fast ISO C bignum library.
|
||||
*
|
||||
* This project is meant to fill in where LibTomMath
|
||||
* falls short. That is speed ;-)
|
||||
*
|
||||
* This project is public domain and free for all purposes.
|
||||
*
|
||||
* Tom St Denis, tomstdenis@gmail.com
|
||||
*/
|
||||
#include <tfm_private.h>
|
||||
|
||||
/* d = a + b (mod c) */
|
||||
@ -10,3 +17,7 @@ int fp_addmod(fp_int *a, fp_int *b, fp_int *c, fp_int *d)
|
||||
fp_add(a, b, &tmp);
|
||||
return fp_mod(&tmp, c, d);
|
||||
}
|
||||
|
||||
/* $Source$ */
|
||||
/* $Revision$ */
|
||||
/* $Date$ */
|
||||
|
@ -1,5 +1,12 @@
|
||||
/* TomsFastMath, a fast ISO C bignum library. -- Tom St Denis */
|
||||
/* SPDX-License-Identifier: Unlicense */
|
||||
/* TomsFastMath, a fast ISO C bignum library.
|
||||
*
|
||||
* This project is meant to fill in where LibTomMath
|
||||
* falls short. That is speed ;-)
|
||||
*
|
||||
* This project is public domain and free for all purposes.
|
||||
*
|
||||
* Tom St Denis, tomstdenis@gmail.com
|
||||
*/
|
||||
#include <tfm_private.h>
|
||||
|
||||
int fp_cmp(fp_int *a, fp_int *b)
|
||||
@ -18,3 +25,7 @@ int fp_cmp(fp_int *a, fp_int *b)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/* $Source$ */
|
||||
/* $Revision$ */
|
||||
/* $Date$ */
|
||||
|
@ -1,5 +1,12 @@
|
||||
/* TomsFastMath, a fast ISO C bignum library. -- Tom St Denis */
|
||||
/* SPDX-License-Identifier: Unlicense */
|
||||
/* TomsFastMath, a fast ISO C bignum library.
|
||||
*
|
||||
* This project is meant to fill in where LibTomMath
|
||||
* falls short. That is speed ;-)
|
||||
*
|
||||
* This project is public domain and free for all purposes.
|
||||
*
|
||||
* Tom St Denis, tomstdenis@gmail.com
|
||||
*/
|
||||
#include <tfm_private.h>
|
||||
|
||||
/* compare against a single digit */
|
||||
@ -25,3 +32,7 @@ int fp_cmp_d(fp_int *a, fp_digit b)
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/* $Source$ */
|
||||
/* $Revision$ */
|
||||
/* $Date$ */
|
||||
|
@ -1,5 +1,12 @@
|
||||
/* TomsFastMath, a fast ISO C bignum library. -- Tom St Denis */
|
||||
/* SPDX-License-Identifier: Unlicense */
|
||||
/* TomsFastMath, a fast ISO C bignum library.
|
||||
*
|
||||
* This project is meant to fill in where LibTomMath
|
||||
* falls short. That is speed ;-)
|
||||
*
|
||||
* This project is public domain and free for all purposes.
|
||||
*
|
||||
* Tom St Denis, tomstdenis@gmail.com
|
||||
*/
|
||||
#include <tfm_private.h>
|
||||
|
||||
int fp_cmp_mag(fp_int *a, fp_int *b)
|
||||
@ -21,3 +28,8 @@ int fp_cmp_mag(fp_int *a, fp_int *b)
|
||||
}
|
||||
return FP_EQ;
|
||||
}
|
||||
|
||||
|
||||
/* $Source$ */
|
||||
/* $Revision$ */
|
||||
/* $Date$ */
|
||||
|
@ -1,5 +1,12 @@
|
||||
/* TomsFastMath, a fast ISO C bignum library. -- Tom St Denis */
|
||||
/* SPDX-License-Identifier: Unlicense */
|
||||
/* TomsFastMath, a fast ISO C bignum library.
|
||||
*
|
||||
* This project is meant to fill in where LibTomMath
|
||||
* falls short. That is speed ;-)
|
||||
*
|
||||
* This project is public domain and free for all purposes.
|
||||
*
|
||||
* Tom St Denis, tomstdenis@gmail.com
|
||||
*/
|
||||
#include <tfm_private.h>
|
||||
|
||||
/* c = a - b */
|
||||
@ -36,3 +43,8 @@ void fp_sub(fp_int *a, fp_int *b, fp_int *c)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/* $Source$ */
|
||||
/* $Revision$ */
|
||||
/* $Date$ */
|
||||
|
@ -1,5 +1,12 @@
|
||||
/* TomsFastMath, a fast ISO C bignum library. -- Tom St Denis */
|
||||
/* SPDX-License-Identifier: Unlicense */
|
||||
/* TomsFastMath, a fast ISO C bignum library.
|
||||
*
|
||||
* This project is meant to fill in where LibTomMath
|
||||
* falls short. That is speed ;-)
|
||||
*
|
||||
* This project is public domain and free for all purposes.
|
||||
*
|
||||
* Tom St Denis, tomstdenis@gmail.com
|
||||
*/
|
||||
#include <tfm_private.h>
|
||||
|
||||
/* c = a - b */
|
||||
@ -9,3 +16,7 @@ void fp_sub_d(fp_int *a, fp_digit b, fp_int *c)
|
||||
fp_set(&tmp, b);
|
||||
fp_sub(a, &tmp, c);
|
||||
}
|
||||
|
||||
/* $Source$ */
|
||||
/* $Revision$ */
|
||||
/* $Date$ */
|
||||
|
@ -1,5 +1,12 @@
|
||||
/* TomsFastMath, a fast ISO C bignum library. -- Tom St Denis */
|
||||
/* SPDX-License-Identifier: Unlicense */
|
||||
/* TomsFastMath, a fast ISO C bignum library.
|
||||
*
|
||||
* This project is meant to fill in where LibTomMath
|
||||
* falls short. That is speed ;-)
|
||||
*
|
||||
* This project is public domain and free for all purposes.
|
||||
*
|
||||
* Tom St Denis, tomstdenis@gmail.com
|
||||
*/
|
||||
#include <tfm_private.h>
|
||||
|
||||
/* d = a - b (mod c) */
|
||||
@ -10,3 +17,8 @@ int fp_submod(fp_int *a, fp_int *b, fp_int *c, fp_int *d)
|
||||
fp_sub(a, b, &tmp);
|
||||
return fp_mod(&tmp, c, d);
|
||||
}
|
||||
|
||||
|
||||
/* $Source$ */
|
||||
/* $Revision$ */
|
||||
/* $Date$ */
|
||||
|
@ -1,5 +1,12 @@
|
||||
/* TomsFastMath, a fast ISO C bignum library. -- Tom St Denis */
|
||||
/* SPDX-License-Identifier: Unlicense */
|
||||
/* TomsFastMath, a fast ISO C bignum library.
|
||||
*
|
||||
* This project is meant to fill in where LibTomMath
|
||||
* falls short. That is speed ;-)
|
||||
*
|
||||
* This project is public domain and free for all purposes.
|
||||
*
|
||||
* Tom St Denis, tomstdenis@gmail.com
|
||||
*/
|
||||
#include <tfm_private.h>
|
||||
|
||||
/* unsigned addition */
|
||||
@ -29,3 +36,7 @@ void s_fp_add(fp_int *a, fp_int *b, fp_int *c)
|
||||
}
|
||||
fp_clamp(c);
|
||||
}
|
||||
|
||||
/* $Source$ */
|
||||
/* $Revision$ */
|
||||
/* $Date$ */
|
||||
|
@ -1,5 +1,12 @@
|
||||
/* TomsFastMath, a fast ISO C bignum library. -- Tom St Denis */
|
||||
/* SPDX-License-Identifier: Unlicense */
|
||||
/* TomsFastMath, a fast ISO C bignum library.
|
||||
*
|
||||
* This project is meant to fill in where LibTomMath
|
||||
* falls short. That is speed ;-)
|
||||
*
|
||||
* This project is public domain and free for all purposes.
|
||||
*
|
||||
* Tom St Denis, tomstdenis@gmail.com
|
||||
*/
|
||||
#include <tfm_private.h>
|
||||
|
||||
/* unsigned subtraction ||a|| >= ||b|| ALWAYS! */
|
||||
@ -27,3 +34,7 @@ void s_fp_sub(fp_int *a, fp_int *b, fp_int *c)
|
||||
}
|
||||
fp_clamp(c);
|
||||
}
|
||||
|
||||
/* $Source$ */
|
||||
/* $Revision$ */
|
||||
/* $Date$ */
|
||||
|
@ -1,5 +1,12 @@
|
||||
/* TomsFastMath, a fast ISO C bignum library. -- Tom St Denis */
|
||||
/* SPDX-License-Identifier: Unlicense */
|
||||
/* TomsFastMath, a fast ISO C bignum library.
|
||||
*
|
||||
* This project is meant to fill in where LibTomMath
|
||||
* falls short. That is speed ;-)
|
||||
*
|
||||
* This project is public domain and free for all purposes.
|
||||
*
|
||||
* Tom St Denis, tomstdenis@gmail.com
|
||||
*/
|
||||
#include <tfm_private.h>
|
||||
|
||||
int fp_radix_size(fp_int *a, int radix, int *size)
|
||||
@ -38,3 +45,7 @@ int fp_radix_size(fp_int *a, int radix, int *size)
|
||||
return FP_OKAY;
|
||||
|
||||
}
|
||||
|
||||
/* $Source$ */
|
||||
/* $Revision$ */
|
||||
/* $Date$ */
|
||||
|
@ -1,5 +1,12 @@
|
||||
/* TomsFastMath, a fast ISO C bignum library. -- Tom St Denis */
|
||||
/* SPDX-License-Identifier: Unlicense */
|
||||
/* TomsFastMath, a fast ISO C bignum library.
|
||||
*
|
||||
* This project is meant to fill in where LibTomMath
|
||||
* falls short. That is speed ;-)
|
||||
*
|
||||
* This project is public domain and free for all purposes.
|
||||
*
|
||||
* Tom St Denis, tomstdenis@gmail.com
|
||||
*/
|
||||
#include <tfm_private.h>
|
||||
|
||||
int fp_read_radix(fp_int *a, const char *str, int radix)
|
||||
@ -57,3 +64,7 @@ int fp_read_radix(fp_int *a, const char *str, int radix)
|
||||
}
|
||||
return FP_OKAY;
|
||||
}
|
||||
|
||||
/* $Source$ */
|
||||
/* $Revision$ */
|
||||
/* $Date$ */
|
||||
|
@ -1,5 +1,12 @@
|
||||
/* TomsFastMath, a fast ISO C bignum library. -- Tom St Denis */
|
||||
/* SPDX-License-Identifier: Unlicense */
|
||||
/* TomsFastMath, a fast ISO C bignum library.
|
||||
*
|
||||
* This project is meant to fill in where LibTomMath
|
||||
* falls short. That is speed ;-)
|
||||
*
|
||||
* This project is public domain and free for all purposes.
|
||||
*
|
||||
* Tom St Denis, tomstdenis@gmail.com
|
||||
*/
|
||||
#include <tfm_private.h>
|
||||
|
||||
void fp_read_signed_bin(fp_int *a, const unsigned char *b, int c)
|
||||
@ -14,3 +21,7 @@ void fp_read_signed_bin(fp_int *a, const unsigned char *b, int c)
|
||||
a->sign = FP_NEG;
|
||||
}
|
||||
}
|
||||
|
||||
/* $Source$ */
|
||||
/* $Revision$ */
|
||||
/* $Date$ */
|
||||
|
@ -1,5 +1,12 @@
|
||||
/* TomsFastMath, a fast ISO C bignum library. -- Tom St Denis */
|
||||
/* SPDX-License-Identifier: Unlicense */
|
||||
/* TomsFastMath, a fast ISO C bignum library.
|
||||
*
|
||||
* This project is meant to fill in where LibTomMath
|
||||
* falls short. That is speed ;-)
|
||||
*
|
||||
* This project is public domain and free for all purposes.
|
||||
*
|
||||
* Tom St Denis, tomstdenis@gmail.com
|
||||
*/
|
||||
#include <tfm_private.h>
|
||||
|
||||
void fp_read_unsigned_bin(fp_int *a, const unsigned char *b, int c)
|
||||
@ -7,12 +14,6 @@ void fp_read_unsigned_bin(fp_int *a, const unsigned char *b, int c)
|
||||
/* zero the int */
|
||||
fp_zero (a);
|
||||
|
||||
if ((unsigned)c > (FP_SIZE * sizeof(fp_digit))) {
|
||||
int excess = c - (FP_SIZE * sizeof(fp_digit));
|
||||
c -= excess;
|
||||
b += excess;
|
||||
}
|
||||
|
||||
/* If we know the endianness of this architecture, and we're using
|
||||
32-bit fp_digits, we can optimize this */
|
||||
#if (defined(ENDIAN_LITTLE) || defined(ENDIAN_BIG)) && !defined(FP_64BIT)
|
||||
@ -23,6 +24,11 @@ void fp_read_unsigned_bin(fp_int *a, const unsigned char *b, int c)
|
||||
{
|
||||
unsigned char *pd = (unsigned char *)a->dp;
|
||||
|
||||
if ((unsigned)c > (FP_SIZE * sizeof(fp_digit))) {
|
||||
int excess = c - (FP_SIZE * sizeof(fp_digit));
|
||||
c -= excess;
|
||||
b += excess;
|
||||
}
|
||||
a->used = (c + sizeof(fp_digit) - 1)/sizeof(fp_digit);
|
||||
/* read the bytes in */
|
||||
#ifdef ENDIAN_BIG
|
||||
@ -49,11 +55,12 @@ void fp_read_unsigned_bin(fp_int *a, const unsigned char *b, int c)
|
||||
for (; c > 0; c--) {
|
||||
fp_mul_2d (a, 8, a);
|
||||
a->dp[0] |= *b++;
|
||||
|
||||
if (a->used == 0) {
|
||||
a->used = 1;
|
||||
}
|
||||
a->used += 1;
|
||||
}
|
||||
#endif
|
||||
fp_clamp (a);
|
||||
}
|
||||
|
||||
/* $Source$ */
|
||||
/* $Revision$ */
|
||||
/* $Date$ */
|
||||
|
@ -1,5 +1,12 @@
|
||||
/* TomsFastMath, a fast ISO C bignum library. -- Tom St Denis */
|
||||
/* SPDX-License-Identifier: Unlicense */
|
||||
/* TomsFastMath, a fast ISO C bignum library.
|
||||
*
|
||||
* This project is meant to fill in where LibTomMath
|
||||
* falls short. That is speed ;-)
|
||||
*
|
||||
* This project is public domain and free for all purposes.
|
||||
*
|
||||
* Tom St Denis, tomstdenis@gmail.com
|
||||
*/
|
||||
#include <tfm_private.h>
|
||||
|
||||
/* reverse an array, used for radix code */
|
||||
@ -18,3 +25,7 @@ void fp_reverse (unsigned char *s, int len)
|
||||
--iy;
|
||||
}
|
||||
}
|
||||
|
||||
/* $Source$ */
|
||||
/* $Revision$ */
|
||||
/* $Date$ */
|
||||
|
@ -1,6 +1,17 @@
|
||||
/* TomsFastMath, a fast ISO C bignum library. -- Tom St Denis */
|
||||
/* SPDX-License-Identifier: Unlicense */
|
||||
/* TomsFastMath, a fast ISO C bignum library.
|
||||
*
|
||||
* This project is meant to fill in where LibTomMath
|
||||
* falls short. That is speed ;-)
|
||||
*
|
||||
* This project is public domain and free for all purposes.
|
||||
*
|
||||
* Tom St Denis, tomstdenis@gmail.com
|
||||
*/
|
||||
#include <tfm_private.h>
|
||||
|
||||
/* chars used in radix conversions */
|
||||
const char *fp_s_rmap = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz+/";
|
||||
|
||||
/* $Source$ */
|
||||
/* $Revision$ */
|
||||
/* $Date$ */
|
||||
|
@ -1,8 +1,19 @@
|
||||
/* TomsFastMath, a fast ISO C bignum library. -- Tom St Denis */
|
||||
/* SPDX-License-Identifier: Unlicense */
|
||||
/* TomsFastMath, a fast ISO C bignum library.
|
||||
*
|
||||
* This project is meant to fill in where LibTomMath
|
||||
* falls short. That is speed ;-)
|
||||
*
|
||||
* This project is public domain and free for all purposes.
|
||||
*
|
||||
* Tom St Denis, tomstdenis@gmail.com
|
||||
*/
|
||||
#include <tfm_private.h>
|
||||
|
||||
int fp_signed_bin_size(fp_int *a)
|
||||
{
|
||||
return 1 + fp_unsigned_bin_size (a);
|
||||
}
|
||||
|
||||
/* $Source$ */
|
||||
/* $Revision$ */
|
||||
/* $Date$ */
|
||||
|
@ -1,5 +1,12 @@
|
||||
/* TomsFastMath, a fast ISO C bignum library. -- Tom St Denis */
|
||||
/* SPDX-License-Identifier: Unlicense */
|
||||
/* TomsFastMath, a fast ISO C bignum library.
|
||||
*
|
||||
* This project is meant to fill in where LibTomMath
|
||||
* falls short. That is speed ;-)
|
||||
*
|
||||
* This project is public domain and free for all purposes.
|
||||
*
|
||||
* Tom St Denis, tomstdenis@gmail.com
|
||||
*/
|
||||
#include <tfm_private.h>
|
||||
|
||||
void fp_to_signed_bin(fp_int *a, unsigned char *b)
|
||||
@ -7,3 +14,7 @@ void fp_to_signed_bin(fp_int *a, unsigned char *b)
|
||||
fp_to_unsigned_bin (a, b + 1);
|
||||
b[0] = (unsigned char) ((a->sign == FP_ZPOS) ? 0 : 1);
|
||||
}
|
||||
|
||||
/* $Source$ */
|
||||
/* $Revision$ */
|
||||
/* $Date$ */
|
||||
|
@ -1,5 +1,12 @@
|
||||
/* TomsFastMath, a fast ISO C bignum library. -- Tom St Denis */
|
||||
/* SPDX-License-Identifier: Unlicense */
|
||||
/* TomsFastMath, a fast ISO C bignum library.
|
||||
*
|
||||
* This project is meant to fill in where LibTomMath
|
||||
* falls short. That is speed ;-)
|
||||
*
|
||||
* This project is public domain and free for all purposes.
|
||||
*
|
||||
* Tom St Denis, tomstdenis@gmail.com
|
||||
*/
|
||||
#include <tfm_private.h>
|
||||
|
||||
void fp_to_unsigned_bin(fp_int *a, unsigned char *b)
|
||||
@ -16,3 +23,7 @@ void fp_to_unsigned_bin(fp_int *a, unsigned char *b)
|
||||
}
|
||||
fp_reverse (b, x);
|
||||
}
|
||||
|
||||
/* $Source$ */
|
||||
/* $Revision$ */
|
||||
/* $Date$ */
|
||||
|
@ -1,5 +1,12 @@
|
||||
/* TomsFastMath, a fast ISO C bignum library. -- Tom St Denis */
|
||||
/* SPDX-License-Identifier: Unlicense */
|
||||
/* TomsFastMath, a fast ISO C bignum library.
|
||||
*
|
||||
* This project is meant to fill in where LibTomMath
|
||||
* falls short. That is speed ;-)
|
||||
*
|
||||
* This project is public domain and free for all purposes.
|
||||
*
|
||||
* Tom St Denis, tomstdenis@gmail.com
|
||||
*/
|
||||
#include <tfm_private.h>
|
||||
|
||||
/**
|
||||
@ -18,3 +25,7 @@ int fp_toradix(fp_int *a, char *str, int radix)
|
||||
{
|
||||
return fp_toradix_n(a, str, radix, INT_MAX);
|
||||
}
|
||||
|
||||
/* $Source$ */
|
||||
/* $Revision$ */
|
||||
/* $Date$ */
|
||||
|
@ -1,12 +1,19 @@
|
||||
/* TomsFastMath, a fast ISO C bignum library. -- Tom St Denis */
|
||||
/* SPDX-License-Identifier: Unlicense */
|
||||
/* TomsFastMath, a fast ISO C bignum library.
|
||||
*
|
||||
* This project is meant to fill in where LibTomMath
|
||||
* falls short. That is speed ;-)
|
||||
*
|
||||
* This project is public domain and free for all purposes.
|
||||
*
|
||||
* Tom St Denis, tomstdenis@gmail.com
|
||||
*/
|
||||
#include <tfm_private.h>
|
||||
|
||||
int fp_toradix_n(fp_int *a, char *str, int radix, int maxlen)
|
||||
{
|
||||
int digs;
|
||||
fp_int t;
|
||||
fp_digit d = 0;
|
||||
fp_digit d;
|
||||
char *_s = str;
|
||||
|
||||
/* check range of the radix */
|
||||
@ -58,3 +65,7 @@ int fp_toradix_n(fp_int *a, char *str, int radix, int maxlen)
|
||||
return FP_VAL;
|
||||
return FP_OKAY;
|
||||
}
|
||||
|
||||
/* $Source$ */
|
||||
/* $Revision$ */
|
||||
/* $Date$ */
|
||||
|
@ -1,5 +1,12 @@
|
||||
/* TomsFastMath, a fast ISO C bignum library. -- Tom St Denis */
|
||||
/* SPDX-License-Identifier: Unlicense */
|
||||
/* TomsFastMath, a fast ISO C bignum library.
|
||||
*
|
||||
* This project is meant to fill in where LibTomMath
|
||||
* falls short. That is speed ;-)
|
||||
*
|
||||
* This project is public domain and free for all purposes.
|
||||
*
|
||||
* Tom St Denis, tomstdenis@gmail.com
|
||||
*/
|
||||
#include <tfm_private.h>
|
||||
|
||||
int fp_unsigned_bin_size(fp_int *a)
|
||||
@ -7,3 +14,7 @@ int fp_unsigned_bin_size(fp_int *a)
|
||||
int size = fp_count_bits (a);
|
||||
return (size / 8 + ((size & 7) != 0 ? 1 : 0));
|
||||
}
|
||||
|
||||
/* $Source$ */
|
||||
/* $Revision$ */
|
||||
/* $Date$ */
|
||||
|
@ -1,5 +1,12 @@
|
||||
/* TomsFastMath, a fast ISO C bignum library. -- Tom St Denis */
|
||||
/* SPDX-License-Identifier: Unlicense */
|
||||
/* TomsFastMath, a fast ISO C bignum library.
|
||||
*
|
||||
* This project is meant to fill in where LibTomMath
|
||||
* falls short. That is speed ;-)
|
||||
*
|
||||
* This project is public domain and free for all purposes.
|
||||
*
|
||||
* Tom St Denis, tomstdenis@gmail.com
|
||||
*/
|
||||
#include <tfm_private.h>
|
||||
|
||||
static const int lnz[16] = {
|
||||
@ -32,3 +39,8 @@ int fp_cnt_lsb(fp_int *a)
|
||||
}
|
||||
return x;
|
||||
}
|
||||
|
||||
|
||||
/* $Source$ */
|
||||
/* $Revision$ */
|
||||
/* $Date$ */
|
||||
|
@ -1,5 +1,12 @@
|
||||
/* TomsFastMath, a fast ISO C bignum library. -- Tom St Denis */
|
||||
/* SPDX-License-Identifier: Unlicense */
|
||||
/* TomsFastMath, a fast ISO C bignum library.
|
||||
*
|
||||
* This project is meant to fill in where LibTomMath
|
||||
* falls short. That is speed ;-)
|
||||
*
|
||||
* This project is public domain and free for all purposes.
|
||||
*
|
||||
* Tom St Denis, tomstdenis@gmail.com
|
||||
*/
|
||||
#include <tfm_private.h>
|
||||
|
||||
int fp_count_bits (fp_int * a)
|
||||
@ -23,3 +30,7 @@ int fp_count_bits (fp_int * a)
|
||||
}
|
||||
return r;
|
||||
}
|
||||
|
||||
/* $Source$ */
|
||||
/* $Revision$ */
|
||||
/* $Date$ */
|
||||
|
@ -1,5 +1,12 @@
|
||||
/* TomsFastMath, a fast ISO C bignum library. -- Tom St Denis */
|
||||
/* SPDX-License-Identifier: Unlicense */
|
||||
/* TomsFastMath, a fast ISO C bignum library.
|
||||
*
|
||||
* This project is meant to fill in where LibTomMath
|
||||
* falls short. That is speed ;-)
|
||||
*
|
||||
* This project is public domain and free for all purposes.
|
||||
*
|
||||
* Tom St Denis, tomstdenis@gmail.com
|
||||
*/
|
||||
#include <tfm_private.h>
|
||||
|
||||
/* b = a/2 */
|
||||
@ -40,3 +47,7 @@ void fp_div_2(fp_int * a, fp_int * b)
|
||||
b->sign = a->sign;
|
||||
fp_clamp (b);
|
||||
}
|
||||
|
||||
/* $Source$ */
|
||||
/* $Revision$ */
|
||||
/* $Date$ */
|
||||
|
@ -1,5 +1,12 @@
|
||||
/* TomsFastMath, a fast ISO C bignum library. -- Tom St Denis */
|
||||
/* SPDX-License-Identifier: Unlicense */
|
||||
/* TomsFastMath, a fast ISO C bignum library.
|
||||
*
|
||||
* This project is meant to fill in where LibTomMath
|
||||
* falls short. That is speed ;-)
|
||||
*
|
||||
* This project is public domain and free for all purposes.
|
||||
*
|
||||
* Tom St Denis, tomstdenis@gmail.com
|
||||
*/
|
||||
#include <tfm_private.h>
|
||||
|
||||
/* c = a / 2**b */
|
||||
@ -66,3 +73,7 @@ void fp_div_2d(fp_int *a, int b, fp_int *c, fp_int *d)
|
||||
fp_copy (&t, d);
|
||||
}
|
||||
}
|
||||
|
||||
/* $Source$ */
|
||||
/* $Revision$ */
|
||||
/* $Date$ */
|
||||
|
@ -1,5 +1,12 @@
|
||||
/* TomsFastMath, a fast ISO C bignum library. -- Tom St Denis */
|
||||
/* SPDX-License-Identifier: Unlicense */
|
||||
/* TomsFastMath, a fast ISO C bignum library.
|
||||
*
|
||||
* This project is meant to fill in where LibTomMath
|
||||
* falls short. That is speed ;-)
|
||||
*
|
||||
* This project is public domain and free for all purposes.
|
||||
*
|
||||
* Tom St Denis, tomstdenis@gmail.com
|
||||
*/
|
||||
#include <tfm_private.h>
|
||||
|
||||
void fp_lshd(fp_int *a, int x)
|
||||
@ -25,3 +32,7 @@ void fp_lshd(fp_int *a, int x)
|
||||
/* clamp digits */
|
||||
fp_clamp(a);
|
||||
}
|
||||
|
||||
/* $Source$ */
|
||||
/* $Revision$ */
|
||||
/* $Date$ */
|
||||
|
@ -1,5 +1,12 @@
|
||||
/* TomsFastMath, a fast ISO C bignum library. -- Tom St Denis */
|
||||
/* SPDX-License-Identifier: Unlicense */
|
||||
/* TomsFastMath, a fast ISO C bignum library.
|
||||
*
|
||||
* This project is meant to fill in where LibTomMath
|
||||
* falls short. That is speed ;-)
|
||||
*
|
||||
* This project is public domain and free for all purposes.
|
||||
*
|
||||
* Tom St Denis, tomstdenis@gmail.com
|
||||
*/
|
||||
#include <tfm_private.h>
|
||||
|
||||
/* c = a mod 2**d */
|
||||
@ -29,3 +36,7 @@ void fp_mod_2d(fp_int *a, int b, fp_int *c)
|
||||
c->dp[b / DIGIT_BIT] &= ~((fp_digit)0) >> (DIGIT_BIT - b);
|
||||
fp_clamp (c);
|
||||
}
|
||||
|
||||
/* $Source$ */
|
||||
/* $Revision$ */
|
||||
/* $Date$ */
|
||||
|
@ -1,5 +1,12 @@
|
||||
/* TomsFastMath, a fast ISO C bignum library. -- Tom St Denis */
|
||||
/* SPDX-License-Identifier: Unlicense */
|
||||
/* TomsFastMath, a fast ISO C bignum library.
|
||||
*
|
||||
* This project is meant to fill in where LibTomMath
|
||||
* falls short. That is speed ;-)
|
||||
*
|
||||
* This project is public domain and free for all purposes.
|
||||
*
|
||||
* Tom St Denis, tomstdenis@gmail.com
|
||||
*/
|
||||
#include <tfm_private.h>
|
||||
|
||||
void fp_rshd(fp_int *a, int x)
|
||||
@ -26,3 +33,8 @@ void fp_rshd(fp_int *a, int x)
|
||||
a->used -= x;
|
||||
fp_clamp(a);
|
||||
}
|
||||
|
||||
|
||||
/* $Source$ */
|
||||
/* $Revision$ */
|
||||
/* $Date$ */
|
||||
|
@ -1,5 +1,12 @@
|
||||
/* TomsFastMath, a fast ISO C bignum library. -- Tom St Denis */
|
||||
/* SPDX-License-Identifier: Unlicense */
|
||||
/* TomsFastMath, a fast ISO C bignum library.
|
||||
*
|
||||
* This project is meant to fill in where LibTomMath
|
||||
* falls short. That is speed ;-)
|
||||
*
|
||||
* This project is public domain and free for all purposes.
|
||||
*
|
||||
* Tom St Denis, tomstdenis@gmail.com
|
||||
*/
|
||||
#include <tfm_private.h>
|
||||
|
||||
/* a/b => cb + d == a */
|
||||
@ -144,3 +151,7 @@ int fp_div(fp_int *a, fp_int *b, fp_int *c, fp_int *d)
|
||||
|
||||
return FP_OKAY;
|
||||
}
|
||||
|
||||
/* $Source$ */
|
||||
/* $Revision$ */
|
||||
/* $Date$ */
|
||||
|
@ -1,5 +1,12 @@
|
||||
/* TomsFastMath, a fast ISO C bignum library. -- Tom St Denis */
|
||||
/* SPDX-License-Identifier: Unlicense */
|
||||
/* TomsFastMath, a fast ISO C bignum library.
|
||||
*
|
||||
* This project is meant to fill in where LibTomMath
|
||||
* falls short. That is speed ;-)
|
||||
*
|
||||
* This project is public domain and free for all purposes.
|
||||
*
|
||||
* Tom St Denis, tomstdenis@gmail.com
|
||||
*/
|
||||
#include <tfm_private.h>
|
||||
|
||||
static int s_is_power_of_two(fp_digit b, int *p)
|
||||
@ -84,3 +91,8 @@ int fp_div_d(fp_int *a, fp_digit b, fp_int *c, fp_digit *d)
|
||||
|
||||
return FP_OKAY;
|
||||
}
|
||||
|
||||
|
||||
/* $Source$ */
|
||||
/* $Revision$ */
|
||||
/* $Date$ */
|
||||
|
@ -1,5 +1,12 @@
|
||||
/* TomsFastMath, a fast ISO C bignum library. -- Tom St Denis */
|
||||
/* SPDX-License-Identifier: Unlicense */
|
||||
/* TomsFastMath, a fast ISO C bignum library.
|
||||
*
|
||||
* This project is meant to fill in where LibTomMath
|
||||
* falls short. That is speed ;-)
|
||||
*
|
||||
* This project is public domain and free for all purposes.
|
||||
*
|
||||
* Tom St Denis, tomstdenis@gmail.com
|
||||
*/
|
||||
#include <tfm_private.h>
|
||||
|
||||
/* c = a mod b, 0 <= c < b */
|
||||
@ -19,3 +26,9 @@ int fp_mod(fp_int *a, fp_int *b, fp_int *c)
|
||||
}
|
||||
return FP_OKAY;
|
||||
}
|
||||
|
||||
|
||||
|
||||
/* $Source$ */
|
||||
/* $Revision$ */
|
||||
/* $Date$ */
|
||||
|
@ -1,5 +1,12 @@
|
||||
/* TomsFastMath, a fast ISO C bignum library. -- Tom St Denis */
|
||||
/* SPDX-License-Identifier: Unlicense */
|
||||
/* TomsFastMath, a fast ISO C bignum library.
|
||||
*
|
||||
* This project is meant to fill in where LibTomMath
|
||||
* falls short. That is speed ;-)
|
||||
*
|
||||
* This project is public domain and free for all purposes.
|
||||
*
|
||||
* Tom St Denis, tomstdenis@gmail.com
|
||||
*/
|
||||
#include <tfm_private.h>
|
||||
|
||||
/* c = a mod b, 0 <= c < b */
|
||||
@ -7,3 +14,7 @@ int fp_mod_d(fp_int *a, fp_digit b, fp_digit *c)
|
||||
{
|
||||
return fp_div_d(a, b, NULL, c);
|
||||
}
|
||||
|
||||
/* $Source$ */
|
||||
/* $Revision$ */
|
||||
/* $Date$ */
|
||||
|
@ -1,5 +1,12 @@
|
||||
/* TomsFastMath, a fast ISO C bignum library. -- Tom St Denis */
|
||||
/* SPDX-License-Identifier: Unlicense */
|
||||
/* TomsFastMath, a fast ISO C bignum library.
|
||||
*
|
||||
* This project is meant to fill in where LibTomMath
|
||||
* falls short. That is speed ;-)
|
||||
*
|
||||
* This project is public domain and free for all purposes.
|
||||
*
|
||||
* Tom St Denis, tomstdenis@gmail.com
|
||||
*/
|
||||
#include <tfm_private.h>
|
||||
|
||||
/* computes a = 2**b */
|
||||
@ -25,3 +32,8 @@ void fp_2expt(fp_int *a, int b)
|
||||
/* put the single bit in its place */
|
||||
a->dp[z] = ((fp_digit)1) << (b % DIGIT_BIT);
|
||||
}
|
||||
|
||||
|
||||
/* $Source$ */
|
||||
/* $Revision$ */
|
||||
/* $Date$ */
|
||||
|
@ -1,5 +1,12 @@
|
||||
/* TomsFastMath, a fast ISO C bignum library. -- Tom St Denis */
|
||||
/* SPDX-License-Identifier: Unlicense */
|
||||
/* TomsFastMath, a fast ISO C bignum library.
|
||||
*
|
||||
* This project is meant to fill in where LibTomMath
|
||||
* falls short. That is speed ;-)
|
||||
*
|
||||
* This project is public domain and free for all purposes.
|
||||
*
|
||||
* Tom St Denis, tomstdenis@gmail.com
|
||||
*/
|
||||
#include <tfm_private.h>
|
||||
|
||||
#ifdef TFM_TIMING_RESISTANT
|
||||
@ -263,3 +270,7 @@ int fp_exptmod(fp_int * G, fp_int * X, fp_int * P, fp_int * Y)
|
||||
return _fp_exptmod(G, X, P, Y);
|
||||
}
|
||||
}
|
||||
|
||||
/* $Source$ */
|
||||
/* $Revision$ */
|
||||
/* $Date$ */
|
||||
|
2
src/generators/.gitignore
vendored
2
src/generators/.gitignore
vendored
@ -1,9 +1,7 @@
|
||||
comba_mont_gen
|
||||
comba_mult_gen
|
||||
comba_mult_smallgen
|
||||
comba_sqr_gen
|
||||
comba_sqr_smallgen
|
||||
comba_mont_gen.exe
|
||||
comba_mult_gen.exe
|
||||
comba_mult_smallgen.exe
|
||||
comba_sqr_gen.exe
|
||||
|
@ -1,19 +1,12 @@
|
||||
/* TomsFastMath, a fast ISO C bignum library. -- Tom St Denis */
|
||||
/* SPDX-License-Identifier: Unlicense */
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
int main(int argc, char **argv)
|
||||
int main(void)
|
||||
{
|
||||
int x, y, z, N = 16;
|
||||
if (argc > 1) N = atoi(argv[1]);
|
||||
int x, y, z;
|
||||
|
||||
printf(
|
||||
#if 1
|
||||
"/* TomsFastMath, a fast ISO C bignum library. -- Tom St Denis */\n"
|
||||
"/* SPDX-License-Identifier: Unlicense */\n"
|
||||
"#ifdef TFM_SMALL_MONT_SET\n"
|
||||
"#ifdef TFM_SMALL_SET\n"
|
||||
"/* computes x/R == x (mod N) via Montgomery Reduction */\n"
|
||||
"void fp_montgomery_reduce_small(fp_int *a, fp_int *m, fp_digit mp)\n"
|
||||
"{\n"
|
||||
@ -41,7 +34,7 @@ printf(
|
||||
"\n"
|
||||
" switch (pa) {\n");
|
||||
|
||||
for (x = 1; x <= N; x++) {
|
||||
for (x = 1; x <= 16; x++) {
|
||||
if (x > 16 && (x != 32 && x != 48 && x != 64)) continue;
|
||||
if (x > 16) printf("#ifdef TFM_HUGE\n");
|
||||
|
||||
|
@ -1,9 +1,15 @@
|
||||
/* TomsFastMath, a fast ISO C bignum library. -- Tom St Denis */
|
||||
/* SPDX-License-Identifier: Unlicense */
|
||||
/* TomsFastMath, a fast ISO C bignum library.
|
||||
*
|
||||
* This project is meant to fill in where LibTomMath
|
||||
* falls short. That is speed ;-)
|
||||
*
|
||||
* This project is public domain and free for all purposes.
|
||||
*
|
||||
* Tom St Denis, tomstdenis@gmail.com
|
||||
*/
|
||||
|
||||
/* program emits a NxN comba multiplier */
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
int main(int argc, char **argv)
|
||||
{
|
||||
@ -12,32 +18,19 @@ int main(int argc, char **argv)
|
||||
|
||||
/* print out preamble */
|
||||
printf(
|
||||
"/* TomsFastMath, a fast ISO C bignum library. -- Tom St Denis */\n"
|
||||
"/* SPDX-License-Identifier: Unlicense */\n"
|
||||
"#ifndef TFM_PRE_GEN_MPI_C\n"
|
||||
"#define TFM_DEFINES\n"
|
||||
"#include \"fp_mul_comba.c\"\n"
|
||||
"#endif\n"
|
||||
"\n"
|
||||
"#if defined(TFM_MUL%d) && FP_SIZE >= %d\n"
|
||||
"void fp_mul_comba%d(fp_int *A, fp_int *B, fp_int *C)\n"
|
||||
"{\n"
|
||||
" fp_digit c0, c1, c2, at[%d];\n", N, N+N, N, N+N);
|
||||
if (N >= 32) {
|
||||
printf(
|
||||
" int out_size;\n"
|
||||
" fp_digit c0, c1, c2, at[%d];\n"
|
||||
"\n"
|
||||
" out_size = A->used + B->used;\n");
|
||||
} else {
|
||||
printf(
|
||||
"\n");
|
||||
}
|
||||
printf(
|
||||
" memcpy(at, A->dp, %d * sizeof(fp_digit));\n"
|
||||
" memcpy(at+%d, B->dp, %d * sizeof(fp_digit));\n"
|
||||
" COMBA_START;\n"
|
||||
"\n"
|
||||
" COMBA_CLEAR;\n", N, N, N);
|
||||
" COMBA_CLEAR;\n", N, N+N, N, N+N, N, N, N);
|
||||
|
||||
/* now do the rows */
|
||||
for (x = 0; x < (N+N-1); x++) {
|
||||
@ -57,14 +50,6 @@ printf(
|
||||
printf(
|
||||
"\n"
|
||||
" COMBA_STORE(C->dp[%d]);\n", x);
|
||||
if (N >= 32 && N*2 != (x+2) &&(x+2) >= 40 && (x+2)%8 == 0) {
|
||||
printf(
|
||||
"\n"
|
||||
" /* early out at %d digits, %d*32==%d, or two %d bit operands */\n"
|
||||
" if (out_size <= %d) { COMBA_STORE2(C->dp[%d]); C->used = %d; C->sign = A->sign ^ B->sign; fp_clamp(C); COMBA_FINI; return; }\n"
|
||||
"\n"
|
||||
, x+2, x+2, (x+2)*32, (x+2)*16, x+2, x+1, x+2);
|
||||
}
|
||||
}
|
||||
printf(
|
||||
" COMBA_STORE2(C->dp[%d]);\n"
|
||||
@ -72,8 +57,15 @@ printf(
|
||||
" C->sign = A->sign ^ B->sign;\n"
|
||||
" fp_clamp(C);\n"
|
||||
" COMBA_FINI;\n"
|
||||
"}\n#endif\n"
|
||||
"}\n#endif\n\n\n"
|
||||
"/* $Source$ */\n"
|
||||
"/* $Revision$ */\n"
|
||||
"/* $Date$ */\n"
|
||||
, N+N-1, N+N);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* $Source$ */
|
||||
/* $Revision$ */
|
||||
/* $Date$ */
|
||||
|
@ -1,6 +1,3 @@
|
||||
/* TomsFastMath, a fast ISO C bignum library. -- Tom St Denis */
|
||||
/* SPDX-License-Identifier: Unlicense */
|
||||
|
||||
/* program emits a NxN comba multiplier for 1x1 to 16x16 */
|
||||
#include <stdio.h>
|
||||
|
||||
@ -10,12 +7,8 @@ int main(int argc, char **argv)
|
||||
|
||||
/* print out preamble */
|
||||
printf(
|
||||
"/* TomsFastMath, a fast ISO C bignum library. -- Tom St Denis */\n"
|
||||
"/* SPDX-License-Identifier: Unlicense */\n"
|
||||
"#ifndef TFM_PRE_GEN_MPI_C\n"
|
||||
"#define TFM_DEFINES\n"
|
||||
"#include \"fp_mul_comba.c\"\n"
|
||||
"#endif\n"
|
||||
"\n"
|
||||
"#if defined(TFM_SMALL_SET)\n"
|
||||
"void fp_mul_comba_small(fp_int *A, fp_int *B, fp_int *C)\n"
|
||||
@ -62,7 +55,14 @@ printf(
|
||||
" COMBA_FINI;\n"
|
||||
" break;\n", N+N-1, N+N);
|
||||
}
|
||||
printf(" }\n}\n\n#endif\n");
|
||||
printf(" }\n}\n\n#endif\n\n\n"
|
||||
"/* $Source$ */\n"
|
||||
"/* $Revision$ */\n"
|
||||
"/* $Date$ */\n");
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* $Source$ */
|
||||
/* $Revision$ */
|
||||
/* $Date$ */
|
||||
|
@ -1,5 +1,12 @@
|
||||
/* TomsFastMath, a fast ISO C bignum library. -- Tom St Denis */
|
||||
/* SPDX-License-Identifier: Unlicense */
|
||||
/* TomsFastMath, a fast ISO C bignum library.
|
||||
*
|
||||
* This project is meant to fill in where LibTomMath
|
||||
* falls short. That is speed ;-)
|
||||
*
|
||||
* This project is public domain and free for all purposes.
|
||||
*
|
||||
* Tom St Denis, tomstdenis@gmail.com
|
||||
*/
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
@ -10,24 +17,13 @@ int main(int argc, char **argv)
|
||||
N = atoi(argv[1]);
|
||||
|
||||
printf(
|
||||
"/* TomsFastMath, a fast ISO C bignum library. -- Tom St Denis */\n"
|
||||
"/* SPDX-License-Identifier: Unlicense */\n"
|
||||
"#ifndef TFM_PRE_GEN_MPI_C\n"
|
||||
"#define TFM_DEFINES\n"
|
||||
"#include \"fp_sqr_comba.c\"\n"
|
||||
"#endif\n"
|
||||
"\n"
|
||||
"#if defined(TFM_SQR%d) && FP_SIZE >= %d\n"
|
||||
"void fp_sqr_comba%d(fp_int *A, fp_int *B)\n"
|
||||
"{\n"
|
||||
" fp_digit *a, b[%d], c0, c1, c2;\n", N, N+N, N, N+N);
|
||||
|
||||
if (N > 4) {
|
||||
printf(
|
||||
" fp_digit sc0, sc1, sc2;\n");
|
||||
}
|
||||
|
||||
printf(
|
||||
" fp_digit *a, b[%d], c0, c1, c2, sc0, sc1, sc2;\n"
|
||||
"#ifdef TFM_ISO\n"
|
||||
" fp_word tt;\n"
|
||||
"#endif\n"
|
||||
@ -40,7 +36,7 @@ printf(
|
||||
"\n"
|
||||
" /* output 0 */\n"
|
||||
" SQRADD(a[0],a[0]);\n"
|
||||
" COMBA_STORE(b[0]);\n");
|
||||
" COMBA_STORE(b[0]);\n", N, N+N, N, N+N);
|
||||
|
||||
for (x = 1; x < N+N-1; x++) {
|
||||
printf(
|
||||
@ -102,8 +98,15 @@ printf(
|
||||
" B->sign = FP_ZPOS;\n"
|
||||
" memcpy(B->dp, b, %d * sizeof(fp_digit));\n"
|
||||
" fp_clamp(B);\n"
|
||||
"}\n#endif\n"
|
||||
"}\n#endif\n\n\n"
|
||||
"/* $Source$ */\n"
|
||||
"/* $Revision$ */\n"
|
||||
"/* $Date$ */\n"
|
||||
, N+N, N+N);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* $Source$ */
|
||||
/* $Revision$ */
|
||||
/* $Date$ */
|
||||
|
@ -1,5 +1,12 @@
|
||||
/* TomsFastMath, a fast ISO C bignum library. -- Tom St Denis */
|
||||
/* SPDX-License-Identifier: Unlicense */
|
||||
/* TomsFastMath, a fast ISO C bignum library.
|
||||
*
|
||||
* This project is meant to fill in where LibTomMath
|
||||
* falls short. That is speed ;-)
|
||||
*
|
||||
* This project is public domain and free for all purposes.
|
||||
*
|
||||
* Tom St Denis, tomstdenis@gmail.com
|
||||
*/
|
||||
|
||||
/* Generates squaring comba code... it learns it knows our secrets! */
|
||||
#include <stdio.h>
|
||||
@ -9,12 +16,8 @@ int main(int argc, char **argv)
|
||||
int x, y, z, N, f;
|
||||
|
||||
printf(
|
||||
"/* TomsFastMath, a fast ISO C bignum library. -- Tom St Denis */\n"
|
||||
"/* SPDX-License-Identifier: Unlicense */\n"
|
||||
"#ifndef TFM_PRE_GEN_MPI_C\n"
|
||||
"#define TFM_DEFINES\n"
|
||||
"#include \"fp_sqr_comba.c\"\n"
|
||||
"#endif\n"
|
||||
"\n"
|
||||
"#if defined(TFM_SMALL_SET)\n"
|
||||
"void fp_sqr_comba_small(fp_int *A, fp_int *B)\n"
|
||||
@ -103,8 +106,15 @@ printf(
|
||||
" break;\n\n", N+N, N+N);
|
||||
}
|
||||
|
||||
printf("}\n}\n\n#endif /* TFM_SMALL_SET */\n"
|
||||
printf("}\n}\n\n#endif /* TFM_SMALL_SET */\n\n"
|
||||
"/* $Source$ */\n"
|
||||
"/* $Revision$ */\n"
|
||||
"/* $Date$ */\n"
|
||||
);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* $Source$ */
|
||||
/* $Revision$ */
|
||||
/* $Date$ */
|
||||
|
@ -1,11 +1,6 @@
|
||||
# TomsFastMath, a fast ISO C bignum library. -- Tom St Denis
|
||||
# SPDX-License-Identifier: Unlicense
|
||||
|
||||
all: comba_sqr_gen comba_sqr_smallgen
|
||||
|
||||
clean:
|
||||
rm -f comba_mont_gen
|
||||
rm -f comba_mont_gen.exe
|
||||
rm -f comba_mult_gen
|
||||
rm -f comba_mult_gen.exe
|
||||
rm -f comba_mult_smallgen
|
||||
@ -15,8 +10,6 @@ clean:
|
||||
rm -f comba_sqr_smallgen
|
||||
rm -f comba_sqr_smallgen.exe
|
||||
|
||||
comba_mont_gen: comba_mont_gen.c
|
||||
gcc -o comba_mont_gen comba_mont_gen.c
|
||||
comba_mult_gen: comba_mult_gen.c
|
||||
gcc -o comba_mult_gen comba_mult_gen.c
|
||||
comba_mult_smallgen: comba_mult_smallgen.c
|
||||
@ -26,8 +19,7 @@ comba_sqr_gen: comba_sqr_gen.c
|
||||
comba_sqr_smallgen: comba_sqr_smallgen.c
|
||||
gcc -o comba_sqr_smallgen comba_sqr_smallgen.c
|
||||
|
||||
regen: comba_mont_gen comba_mult_gen comba_mult_smallgen comba_sqr_gen comba_sqr_smallgen
|
||||
./comba_mont_gen > ../mont/fp_mont_small.i
|
||||
regen: comba_mult_gen comba_mult_smallgen comba_sqr_gen comba_sqr_smallgen
|
||||
for i in 3 4 6 7 8 9 12 17 20 24 28 32 48 64; do \
|
||||
./comba_mult_gen $$i | sed -e 's/ *$$//' > ../mul/fp_mul_comba_$$i.c; \
|
||||
done
|
||||
@ -36,3 +28,4 @@ regen: comba_mont_gen comba_mult_gen comba_mult_smallgen comba_sqr_gen comba_sqr
|
||||
./comba_sqr_gen $$i | sed -e 's/ *$$//' > ../sqr/fp_sqr_comba_$$i.c; \
|
||||
done
|
||||
./comba_sqr_smallgen > ../sqr/fp_sqr_comba_small_set.c
|
||||
|
||||
|
@ -1,11 +1,12 @@
|
||||
/* TomsFastMath, a fast ISO C bignum library. -- Tom St Denis
|
||||
/* TomsFastMath, a fast ISO C bignum library.
|
||||
*
|
||||
* This project is meant to fill in where LibTomMath
|
||||
* falls short. That is speed ;-)
|
||||
*
|
||||
* This project is public domain and free for all purposes.
|
||||
*
|
||||
* Tom St Denis, tomstdenis@gmail.com
|
||||
*/
|
||||
/* SPDX-License-Identifier: Unlicense */
|
||||
#ifndef TFM_H_
|
||||
#define TFM_H_
|
||||
|
||||
@ -15,14 +16,14 @@
|
||||
#include <ctype.h>
|
||||
#include <limits.h>
|
||||
|
||||
/* 0xMaMiPaDe
|
||||
/* 0xMaMiPaXX
|
||||
* Major
|
||||
* Minor
|
||||
* Patch
|
||||
* Development - 00=release, 01=in-development
|
||||
* XX - undefined
|
||||
*/
|
||||
#define TFM_VERSION 0x000D0101
|
||||
#define TFM_VERSION_S "v0.13.1-next"
|
||||
#define TFM_VERSION 0x000D0100
|
||||
#define TFM_VERSION_S "v0.13.1"
|
||||
|
||||
#ifndef MIN
|
||||
#define MIN(x,y) ((x)<(y)?(x):(y))
|
||||
@ -334,7 +335,7 @@ const char *fp_ident(void);
|
||||
|
||||
/* zero/even/odd ? */
|
||||
#define fp_iszero(a) (((a)->used == 0) ? FP_YES : FP_NO)
|
||||
#define fp_iseven(a) (((a)->used == 0 || (((a)->dp[0] & 1) == 0)) ? FP_YES : FP_NO)
|
||||
#define fp_iseven(a) (((a)->used >= 0 && (((a)->dp[0] & 1) == 0)) ? FP_YES : FP_NO)
|
||||
#define fp_isodd(a) (((a)->used > 0 && (((a)->dp[0] & 1) == 1)) ? FP_YES : FP_NO)
|
||||
|
||||
/* set to a small digit */
|
||||
@ -491,3 +492,7 @@ int fp_toradix(fp_int *a, char *str, int radix);
|
||||
int fp_toradix_n(fp_int * a, char *str, int radix, int maxlen);
|
||||
|
||||
#endif
|
||||
|
||||
/* $Source$ */
|
||||
/* $Revision$ */
|
||||
/* $Date$ */
|
||||
|
@ -1,9 +1,16 @@
|
||||
/* TomsFastMath, a fast ISO C bignum library. -- Tom St Denis */
|
||||
/* SPDX-License-Identifier: Unlicense */
|
||||
/* TomsFastMath, a fast ISO C bignum library.
|
||||
*
|
||||
* This project is meant to fill in where LibTomMath
|
||||
* falls short. That is speed ;-)
|
||||
*
|
||||
* This project is public domain and free for all purposes.
|
||||
*
|
||||
* Tom St Denis, tomstdenis@gmail.com
|
||||
*/
|
||||
#ifndef TFM_PRIVATE_H_
|
||||
#define TFM_PRIVATE_H_
|
||||
|
||||
#include "tfm.h"
|
||||
#include <tfm.h>
|
||||
|
||||
/* VARIOUS LOW LEVEL STUFFS */
|
||||
void s_fp_add(fp_int *a, fp_int *b, fp_int *c);
|
||||
@ -112,3 +119,7 @@ void fp_sqr_comba64(fp_int *A, fp_int *B);
|
||||
extern const char *fp_s_rmap;
|
||||
|
||||
#endif
|
||||
|
||||
/* $Source$ */
|
||||
/* $Revision$ */
|
||||
/* $Date$ */
|
||||
|
@ -1,18 +1,21 @@
|
||||
/* TomsFastMath, a fast ISO C bignum library. -- Tom St Denis */
|
||||
/* SPDX-License-Identifier: Unlicense */
|
||||
/* TomsFastMath, a fast ISO C bignum library.
|
||||
*
|
||||
* This project is meant to fill in where LibTomMath
|
||||
* falls short. That is speed ;-)
|
||||
*
|
||||
* This project is public domain and free for all purposes.
|
||||
*
|
||||
* Tom St Denis, tomstdenis@gmail.com
|
||||
*/
|
||||
#include <tfm_private.h>
|
||||
|
||||
#ifndef GIT_VERSION
|
||||
#define GIT_VERSION TFM_VERSION_S
|
||||
#endif
|
||||
|
||||
const char *fp_ident(void)
|
||||
{
|
||||
static char buf[1024];
|
||||
|
||||
memset(buf, 0, sizeof(buf));
|
||||
snprintf(buf, sizeof(buf)-1,
|
||||
"TomsFastMath " GIT_VERSION "\n"
|
||||
"TomsFastMath " TFM_VERSION_S "\n"
|
||||
#if defined(TFM_IDENT_BUILD_DATE)
|
||||
"Built on " __DATE__ " at " __TIME__ "\n"
|
||||
#endif
|
||||
@ -88,3 +91,8 @@ int main(void)
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
/* $Source$ */
|
||||
/* $Revision$ */
|
||||
/* $Date$ */
|
||||
|
@ -1,5 +1,12 @@
|
||||
/* TomsFastMath, a fast ISO C bignum library. -- Tom St Denis */
|
||||
/* SPDX-License-Identifier: Unlicense */
|
||||
/* TomsFastMath, a fast ISO C bignum library.
|
||||
*
|
||||
* This project is meant to fill in where LibTomMath
|
||||
* falls short. That is speed ;-)
|
||||
*
|
||||
* This project is public domain and free for all purposes.
|
||||
*
|
||||
* Tom St Denis, tomstdenis@gmail.com
|
||||
*/
|
||||
#include <tfm_private.h>
|
||||
|
||||
#if FP_GEN_RANDOM_MAX == 0xffffffff
|
||||
@ -52,3 +59,7 @@ void fp_rand(fp_int *a, int digits)
|
||||
return;
|
||||
|
||||
}
|
||||
|
||||
/* $Source$ */
|
||||
/* $Revision$ */
|
||||
/* $Date$ */
|
||||
|
@ -1,5 +1,12 @@
|
||||
/* TomsFastMath, a fast ISO C bignum library. -- Tom St Denis */
|
||||
/* SPDX-License-Identifier: Unlicense */
|
||||
/* TomsFastMath, a fast ISO C bignum library.
|
||||
*
|
||||
* This project is meant to fill in where LibTomMath
|
||||
* falls short. That is speed ;-)
|
||||
*
|
||||
* This project is public domain and free for all purposes.
|
||||
*
|
||||
* Tom St Denis, tomstdenis@gmail.com
|
||||
*/
|
||||
#include <tfm_private.h>
|
||||
|
||||
void fp_set(fp_int *a, fp_digit b)
|
||||
@ -8,3 +15,7 @@ void fp_set(fp_int *a, fp_digit b)
|
||||
a->dp[0] = b;
|
||||
a->used = a->dp[0] ? 1 : 0;
|
||||
}
|
||||
|
||||
/* $Source$ */
|
||||
/* $Revision$ */
|
||||
/* $Date$ */
|
||||
|
@ -1,5 +1,3 @@
|
||||
/* TomsFastMath, a fast ISO C bignum library. -- Tom St Denis */
|
||||
/* SPDX-License-Identifier: Unlicense */
|
||||
#ifdef TFM_SMALL_MONT_SET
|
||||
/* computes x/R == x (mod N) via Montgomery Reduction */
|
||||
void fp_montgomery_reduce_small(fp_int *a, fp_int *m, fp_digit mp)
|
||||
|
@ -1,5 +1,12 @@
|
||||
/* TomsFastMath, a fast ISO C bignum library. -- Tom St Denis */
|
||||
/* SPDX-License-Identifier: Unlicense */
|
||||
/* TomsFastMath, a fast ISO C bignum library.
|
||||
*
|
||||
* This project is meant to fill in where LibTomMath
|
||||
* falls short. That is speed ;-)
|
||||
*
|
||||
* This project is public domain and free for all purposes.
|
||||
*
|
||||
* Tom St Denis, tomstdenis@gmail.com
|
||||
*/
|
||||
#include <tfm_private.h>
|
||||
|
||||
/* computes a = B**n mod b without division or multiplication useful for
|
||||
@ -29,3 +36,8 @@ void fp_montgomery_calc_normalization(fp_int *a, fp_int *b)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/* $Source$ */
|
||||
/* $Revision$ */
|
||||
/* $Date$ */
|
||||
|
@ -1,5 +1,12 @@
|
||||
/* TomsFastMath, a fast ISO C bignum library. -- Tom St Denis */
|
||||
/* SPDX-License-Identifier: Unlicense */
|
||||
/* TomsFastMath, a fast ISO C bignum library.
|
||||
*
|
||||
* This project is meant to fill in where LibTomMath
|
||||
* falls short. That is speed ;-)
|
||||
*
|
||||
* This project is public domain and free for all purposes.
|
||||
*
|
||||
* Tom St Denis, tomstdenis@gmail.com
|
||||
*/
|
||||
#include <tfm_private.h>
|
||||
|
||||
/******************************************************************/
|
||||
@ -293,7 +300,7 @@ asm( \
|
||||
" MOVCC %0,#0 \n\t" \
|
||||
" UMLAL r0,%0,%3,%4 \n\t" \
|
||||
" STR r0,%1 \n\t" \
|
||||
:"=r"(cy),"=m"(_c[0]):"0"(cy),"r"(mu),"r"(*tmpm++),"m"(_c[0]):"r0","cc");
|
||||
:"=r"(cy),"=m"(_c[0]):"0"(cy),"r"(mu),"r"(*tmpm++),"1"(_c[0]):"r0","cc");
|
||||
|
||||
#define PROPCARRY \
|
||||
asm( \
|
||||
@ -302,7 +309,7 @@ asm( \
|
||||
" STR r0,%1 \n\t" \
|
||||
" MOVCS %0,#1 \n\t" \
|
||||
" MOVCC %0,#0 \n\t" \
|
||||
:"=r"(cy),"=m"(_c[0]):"0"(cy),"m"(_c[0]):"r0","cc");
|
||||
:"=r"(cy),"=m"(_c[0]):"0"(cy),"1"(_c[0]):"r0","cc");
|
||||
|
||||
/******************************************************************/
|
||||
#elif defined(TFM_PPC32)
|
||||
@ -538,3 +545,8 @@ void fp_montgomery_reduce(fp_int *a, fp_int *m, fp_digit mp)
|
||||
s_fp_sub (a, m, a);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/* $Source$ */
|
||||
/* $Revision$ */
|
||||
/* $Date$ */
|
||||
|
@ -1,5 +1,12 @@
|
||||
/* TomsFastMath, a fast ISO C bignum library. -- Tom St Denis */
|
||||
/* SPDX-License-Identifier: Unlicense */
|
||||
/* TomsFastMath, a fast ISO C bignum library.
|
||||
*
|
||||
* This project is meant to fill in where LibTomMath
|
||||
* falls short. That is speed ;-)
|
||||
*
|
||||
* This project is public domain and free for all purposes.
|
||||
*
|
||||
* Tom St Denis, tomstdenis@gmail.com
|
||||
*/
|
||||
#include <tfm_private.h>
|
||||
|
||||
/* setups the montgomery reduction */
|
||||
@ -34,3 +41,8 @@ int fp_montgomery_setup(fp_int *a, fp_digit *rho)
|
||||
|
||||
return FP_OKAY;
|
||||
}
|
||||
|
||||
|
||||
/* $Source$ */
|
||||
/* $Revision$ */
|
||||
/* $Date$ */
|
||||
|
@ -1,5 +1,12 @@
|
||||
/* TomsFastMath, a fast ISO C bignum library. -- Tom St Denis */
|
||||
/* SPDX-License-Identifier: Unlicense */
|
||||
/* TomsFastMath, a fast ISO C bignum library.
|
||||
*
|
||||
* This project is meant to fill in where LibTomMath
|
||||
* falls short. That is speed ;-)
|
||||
*
|
||||
* This project is public domain and free for all purposes.
|
||||
*
|
||||
* Tom St Denis, tomstdenis@gmail.com
|
||||
*/
|
||||
#include <tfm_private.h>
|
||||
|
||||
/* c = a * b */
|
||||
@ -125,3 +132,8 @@ clean:
|
||||
C->dp[y] = 0;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/* $Source: /cvs/libtom/tomsfastmath/src/mul/fp_mul.c,v $ */
|
||||
/* $Revision: 1.1 $ */
|
||||
/* $Date: 2006/12/31 21:25:53 $ */
|
||||
|
@ -1,5 +1,12 @@
|
||||
/* TomsFastMath, a fast ISO C bignum library. -- Tom St Denis */
|
||||
/* SPDX-License-Identifier: Unlicense */
|
||||
/* TomsFastMath, a fast ISO C bignum library.
|
||||
*
|
||||
* This project is meant to fill in where LibTomMath
|
||||
* falls short. That is speed ;-)
|
||||
*
|
||||
* This project is public domain and free for all purposes.
|
||||
*
|
||||
* Tom St Denis, tomstdenis@gmail.com
|
||||
*/
|
||||
#include <tfm_private.h>
|
||||
|
||||
void fp_mul_2(fp_int * a, fp_int * b)
|
||||
@ -53,3 +60,8 @@ void fp_mul_2(fp_int * a, fp_int * b)
|
||||
}
|
||||
b->sign = a->sign;
|
||||
}
|
||||
|
||||
|
||||
/* $Source$ */
|
||||
/* $Revision$ */
|
||||
/* $Date$ */
|
||||
|
@ -1,5 +1,12 @@
|
||||
/* TomsFastMath, a fast ISO C bignum library. -- Tom St Denis */
|
||||
/* SPDX-License-Identifier: Unlicense */
|
||||
/* TomsFastMath, a fast ISO C bignum library.
|
||||
*
|
||||
* This project is meant to fill in where LibTomMath
|
||||
* falls short. That is speed ;-)
|
||||
*
|
||||
* This project is public domain and free for all purposes.
|
||||
*
|
||||
* Tom St Denis, tomstdenis@gmail.com
|
||||
*/
|
||||
#include <tfm_private.h>
|
||||
|
||||
/* c = a * 2**d */
|
||||
@ -33,3 +40,8 @@ void fp_mul_2d(fp_int *a, int b, fp_int *c)
|
||||
}
|
||||
fp_clamp(c);
|
||||
}
|
||||
|
||||
|
||||
/* $Source$ */
|
||||
/* $Revision$ */
|
||||
/* $Date$ */
|
||||
|
@ -1,5 +1,12 @@
|
||||
/* TomsFastMath, a fast ISO C bignum library. -- Tom St Denis */
|
||||
/* SPDX-License-Identifier: Unlicense */
|
||||
/* TomsFastMath, a fast ISO C bignum library.
|
||||
*
|
||||
* This project is meant to fill in where LibTomMath
|
||||
* falls short. That is speed ;-)
|
||||
*
|
||||
* This project is public domain and free for all purposes.
|
||||
*
|
||||
* Tom St Denis, tomstdenis@gmail.com
|
||||
*/
|
||||
|
||||
/* About this file...
|
||||
|
||||
@ -359,3 +366,8 @@ void fp_mul_comba(fp_int *A, fp_int *B, fp_int *C)
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
/* $Source$ */
|
||||
/* $Revision$ */
|
||||
/* $Date$ */
|
||||
|
||||
|
@ -1,9 +1,5 @@
|
||||
/* TomsFastMath, a fast ISO C bignum library. -- Tom St Denis */
|
||||
/* SPDX-License-Identifier: Unlicense */
|
||||
#ifndef TFM_PRE_GEN_MPI_C
|
||||
#define TFM_DEFINES
|
||||
#include "fp_mul_comba.c"
|
||||
#endif
|
||||
|
||||
#if defined(TFM_MUL12) && FP_SIZE >= 24
|
||||
void fp_mul_comba12(fp_int *A, fp_int *B, fp_int *C)
|
||||
@ -113,3 +109,8 @@ void fp_mul_comba12(fp_int *A, fp_int *B, fp_int *C)
|
||||
COMBA_FINI;
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
/* $Source$ */
|
||||
/* $Revision$ */
|
||||
/* $Date$ */
|
||||
|
@ -1,9 +1,5 @@
|
||||
/* TomsFastMath, a fast ISO C bignum library. -- Tom St Denis */
|
||||
/* SPDX-License-Identifier: Unlicense */
|
||||
#ifndef TFM_PRE_GEN_MPI_C
|
||||
#define TFM_DEFINES
|
||||
#include "fp_mul_comba.c"
|
||||
#endif
|
||||
|
||||
#if defined(TFM_MUL17) && FP_SIZE >= 34
|
||||
void fp_mul_comba17(fp_int *A, fp_int *B, fp_int *C)
|
||||
@ -153,3 +149,8 @@ void fp_mul_comba17(fp_int *A, fp_int *B, fp_int *C)
|
||||
COMBA_FINI;
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
/* $Source$ */
|
||||
/* $Revision$ */
|
||||
/* $Date$ */
|
||||
|
@ -1,9 +1,5 @@
|
||||
/* TomsFastMath, a fast ISO C bignum library. -- Tom St Denis */
|
||||
/* SPDX-License-Identifier: Unlicense */
|
||||
#ifndef TFM_PRE_GEN_MPI_C
|
||||
#define TFM_DEFINES
|
||||
#include "fp_mul_comba.c"
|
||||
#endif
|
||||
|
||||
#if defined(TFM_MUL20) && FP_SIZE >= 40
|
||||
void fp_mul_comba20(fp_int *A, fp_int *B, fp_int *C)
|
||||
@ -177,3 +173,8 @@ void fp_mul_comba20(fp_int *A, fp_int *B, fp_int *C)
|
||||
COMBA_FINI;
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
/* $Source$ */
|
||||
/* $Revision$ */
|
||||
/* $Date$ */
|
||||
|
@ -1,9 +1,5 @@
|
||||
/* TomsFastMath, a fast ISO C bignum library. -- Tom St Denis */
|
||||
/* SPDX-License-Identifier: Unlicense */
|
||||
#ifndef TFM_PRE_GEN_MPI_C
|
||||
#define TFM_DEFINES
|
||||
#include "fp_mul_comba.c"
|
||||
#endif
|
||||
|
||||
#if defined(TFM_MUL24) && FP_SIZE >= 48
|
||||
void fp_mul_comba24(fp_int *A, fp_int *B, fp_int *C)
|
||||
@ -209,3 +205,8 @@ void fp_mul_comba24(fp_int *A, fp_int *B, fp_int *C)
|
||||
COMBA_FINI;
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
/* $Source$ */
|
||||
/* $Revision$ */
|
||||
/* $Date$ */
|
||||
|
@ -1,9 +1,5 @@
|
||||
/* TomsFastMath, a fast ISO C bignum library. -- Tom St Denis */
|
||||
/* SPDX-License-Identifier: Unlicense */
|
||||
#ifndef TFM_PRE_GEN_MPI_C
|
||||
#define TFM_DEFINES
|
||||
#include "fp_mul_comba.c"
|
||||
#endif
|
||||
|
||||
#if defined(TFM_MUL28) && FP_SIZE >= 56
|
||||
void fp_mul_comba28(fp_int *A, fp_int *B, fp_int *C)
|
||||
@ -241,3 +237,8 @@ void fp_mul_comba28(fp_int *A, fp_int *B, fp_int *C)
|
||||
COMBA_FINI;
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
/* $Source$ */
|
||||
/* $Revision$ */
|
||||
/* $Date$ */
|
||||
|
@ -1,9 +1,5 @@
|
||||
/* TomsFastMath, a fast ISO C bignum library. -- Tom St Denis */
|
||||
/* SPDX-License-Identifier: Unlicense */
|
||||
#ifndef TFM_PRE_GEN_MPI_C
|
||||
#define TFM_DEFINES
|
||||
#include "fp_mul_comba.c"
|
||||
#endif
|
||||
|
||||
#if defined(TFM_MUL3) && FP_SIZE >= 6
|
||||
void fp_mul_comba3(fp_int *A, fp_int *B, fp_int *C)
|
||||
@ -41,3 +37,8 @@ void fp_mul_comba3(fp_int *A, fp_int *B, fp_int *C)
|
||||
COMBA_FINI;
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
/* $Source$ */
|
||||
/* $Revision$ */
|
||||
/* $Date$ */
|
||||
|
@ -1,9 +1,5 @@
|
||||
/* TomsFastMath, a fast ISO C bignum library. -- Tom St Denis */
|
||||
/* SPDX-License-Identifier: Unlicense */
|
||||
#ifndef TFM_PRE_GEN_MPI_C
|
||||
#define TFM_DEFINES
|
||||
#include "fp_mul_comba.c"
|
||||
#endif
|
||||
|
||||
#if defined(TFM_MUL32) && FP_SIZE >= 64
|
||||
void fp_mul_comba32(fp_int *A, fp_int *B, fp_int *C)
|
||||
@ -287,3 +283,8 @@ void fp_mul_comba32(fp_int *A, fp_int *B, fp_int *C)
|
||||
COMBA_FINI;
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
/* $Source$ */
|
||||
/* $Revision$ */
|
||||
/* $Date$ */
|
||||
|
@ -1,9 +1,5 @@
|
||||
/* TomsFastMath, a fast ISO C bignum library. -- Tom St Denis */
|
||||
/* SPDX-License-Identifier: Unlicense */
|
||||
#ifndef TFM_PRE_GEN_MPI_C
|
||||
#define TFM_DEFINES
|
||||
#include "fp_mul_comba.c"
|
||||
#endif
|
||||
|
||||
#if defined(TFM_MUL4) && FP_SIZE >= 8
|
||||
void fp_mul_comba4(fp_int *A, fp_int *B, fp_int *C)
|
||||
@ -49,3 +45,8 @@ void fp_mul_comba4(fp_int *A, fp_int *B, fp_int *C)
|
||||
COMBA_FINI;
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
/* $Source$ */
|
||||
/* $Revision$ */
|
||||
/* $Date$ */
|
||||
|
@ -1,17 +1,11 @@
|
||||
/* TomsFastMath, a fast ISO C bignum library. -- Tom St Denis */
|
||||
/* SPDX-License-Identifier: Unlicense */
|
||||
#ifndef TFM_PRE_GEN_MPI_C
|
||||
#define TFM_DEFINES
|
||||
#include "fp_mul_comba.c"
|
||||
#endif
|
||||
|
||||
#if defined(TFM_MUL48) && FP_SIZE >= 96
|
||||
void fp_mul_comba48(fp_int *A, fp_int *B, fp_int *C)
|
||||
{
|
||||
fp_digit c0, c1, c2, at[96];
|
||||
int out_size;
|
||||
|
||||
out_size = A->used + B->used;
|
||||
memcpy(at, A->dp, 48 * sizeof(fp_digit));
|
||||
memcpy(at+48, B->dp, 48 * sizeof(fp_digit));
|
||||
COMBA_START;
|
||||
@ -172,10 +166,6 @@ void fp_mul_comba48(fp_int *A, fp_int *B, fp_int *C)
|
||||
COMBA_FORWARD;
|
||||
MULADD(at[0], at[86]); MULADD(at[1], at[85]); MULADD(at[2], at[84]); MULADD(at[3], at[83]); MULADD(at[4], at[82]); MULADD(at[5], at[81]); MULADD(at[6], at[80]); MULADD(at[7], at[79]); MULADD(at[8], at[78]); MULADD(at[9], at[77]); MULADD(at[10], at[76]); MULADD(at[11], at[75]); MULADD(at[12], at[74]); MULADD(at[13], at[73]); MULADD(at[14], at[72]); MULADD(at[15], at[71]); MULADD(at[16], at[70]); MULADD(at[17], at[69]); MULADD(at[18], at[68]); MULADD(at[19], at[67]); MULADD(at[20], at[66]); MULADD(at[21], at[65]); MULADD(at[22], at[64]); MULADD(at[23], at[63]); MULADD(at[24], at[62]); MULADD(at[25], at[61]); MULADD(at[26], at[60]); MULADD(at[27], at[59]); MULADD(at[28], at[58]); MULADD(at[29], at[57]); MULADD(at[30], at[56]); MULADD(at[31], at[55]); MULADD(at[32], at[54]); MULADD(at[33], at[53]); MULADD(at[34], at[52]); MULADD(at[35], at[51]); MULADD(at[36], at[50]); MULADD(at[37], at[49]); MULADD(at[38], at[48]);
|
||||
COMBA_STORE(C->dp[38]);
|
||||
|
||||
/* early out at 40 digits, 40*32==1280, or two 640 bit operands */
|
||||
if (out_size <= 40) { COMBA_STORE2(C->dp[39]); C->used = 40; C->sign = A->sign ^ B->sign; fp_clamp(C); COMBA_FINI; return; }
|
||||
|
||||
/* 39 */
|
||||
COMBA_FORWARD;
|
||||
MULADD(at[0], at[87]); MULADD(at[1], at[86]); MULADD(at[2], at[85]); MULADD(at[3], at[84]); MULADD(at[4], at[83]); MULADD(at[5], at[82]); MULADD(at[6], at[81]); MULADD(at[7], at[80]); MULADD(at[8], at[79]); MULADD(at[9], at[78]); MULADD(at[10], at[77]); MULADD(at[11], at[76]); MULADD(at[12], at[75]); MULADD(at[13], at[74]); MULADD(at[14], at[73]); MULADD(at[15], at[72]); MULADD(at[16], at[71]); MULADD(at[17], at[70]); MULADD(at[18], at[69]); MULADD(at[19], at[68]); MULADD(at[20], at[67]); MULADD(at[21], at[66]); MULADD(at[22], at[65]); MULADD(at[23], at[64]); MULADD(at[24], at[63]); MULADD(at[25], at[62]); MULADD(at[26], at[61]); MULADD(at[27], at[60]); MULADD(at[28], at[59]); MULADD(at[29], at[58]); MULADD(at[30], at[57]); MULADD(at[31], at[56]); MULADD(at[32], at[55]); MULADD(at[33], at[54]); MULADD(at[34], at[53]); MULADD(at[35], at[52]); MULADD(at[36], at[51]); MULADD(at[37], at[50]); MULADD(at[38], at[49]); MULADD(at[39], at[48]);
|
||||
@ -208,10 +198,6 @@ void fp_mul_comba48(fp_int *A, fp_int *B, fp_int *C)
|
||||
COMBA_FORWARD;
|
||||
MULADD(at[0], at[94]); MULADD(at[1], at[93]); MULADD(at[2], at[92]); MULADD(at[3], at[91]); MULADD(at[4], at[90]); MULADD(at[5], at[89]); MULADD(at[6], at[88]); MULADD(at[7], at[87]); MULADD(at[8], at[86]); MULADD(at[9], at[85]); MULADD(at[10], at[84]); MULADD(at[11], at[83]); MULADD(at[12], at[82]); MULADD(at[13], at[81]); MULADD(at[14], at[80]); MULADD(at[15], at[79]); MULADD(at[16], at[78]); MULADD(at[17], at[77]); MULADD(at[18], at[76]); MULADD(at[19], at[75]); MULADD(at[20], at[74]); MULADD(at[21], at[73]); MULADD(at[22], at[72]); MULADD(at[23], at[71]); MULADD(at[24], at[70]); MULADD(at[25], at[69]); MULADD(at[26], at[68]); MULADD(at[27], at[67]); MULADD(at[28], at[66]); MULADD(at[29], at[65]); MULADD(at[30], at[64]); MULADD(at[31], at[63]); MULADD(at[32], at[62]); MULADD(at[33], at[61]); MULADD(at[34], at[60]); MULADD(at[35], at[59]); MULADD(at[36], at[58]); MULADD(at[37], at[57]); MULADD(at[38], at[56]); MULADD(at[39], at[55]); MULADD(at[40], at[54]); MULADD(at[41], at[53]); MULADD(at[42], at[52]); MULADD(at[43], at[51]); MULADD(at[44], at[50]); MULADD(at[45], at[49]); MULADD(at[46], at[48]);
|
||||
COMBA_STORE(C->dp[46]);
|
||||
|
||||
/* early out at 48 digits, 48*32==1536, or two 768 bit operands */
|
||||
if (out_size <= 48) { COMBA_STORE2(C->dp[47]); C->used = 48; C->sign = A->sign ^ B->sign; fp_clamp(C); COMBA_FINI; return; }
|
||||
|
||||
/* 47 */
|
||||
COMBA_FORWARD;
|
||||
MULADD(at[0], at[95]); MULADD(at[1], at[94]); MULADD(at[2], at[93]); MULADD(at[3], at[92]); MULADD(at[4], at[91]); MULADD(at[5], at[90]); MULADD(at[6], at[89]); MULADD(at[7], at[88]); MULADD(at[8], at[87]); MULADD(at[9], at[86]); MULADD(at[10], at[85]); MULADD(at[11], at[84]); MULADD(at[12], at[83]); MULADD(at[13], at[82]); MULADD(at[14], at[81]); MULADD(at[15], at[80]); MULADD(at[16], at[79]); MULADD(at[17], at[78]); MULADD(at[18], at[77]); MULADD(at[19], at[76]); MULADD(at[20], at[75]); MULADD(at[21], at[74]); MULADD(at[22], at[73]); MULADD(at[23], at[72]); MULADD(at[24], at[71]); MULADD(at[25], at[70]); MULADD(at[26], at[69]); MULADD(at[27], at[68]); MULADD(at[28], at[67]); MULADD(at[29], at[66]); MULADD(at[30], at[65]); MULADD(at[31], at[64]); MULADD(at[32], at[63]); MULADD(at[33], at[62]); MULADD(at[34], at[61]); MULADD(at[35], at[60]); MULADD(at[36], at[59]); MULADD(at[37], at[58]); MULADD(at[38], at[57]); MULADD(at[39], at[56]); MULADD(at[40], at[55]); MULADD(at[41], at[54]); MULADD(at[42], at[53]); MULADD(at[43], at[52]); MULADD(at[44], at[51]); MULADD(at[45], at[50]); MULADD(at[46], at[49]); MULADD(at[47], at[48]);
|
||||
@ -244,10 +230,6 @@ void fp_mul_comba48(fp_int *A, fp_int *B, fp_int *C)
|
||||
COMBA_FORWARD;
|
||||
MULADD(at[7], at[95]); MULADD(at[8], at[94]); MULADD(at[9], at[93]); MULADD(at[10], at[92]); MULADD(at[11], at[91]); MULADD(at[12], at[90]); MULADD(at[13], at[89]); MULADD(at[14], at[88]); MULADD(at[15], at[87]); MULADD(at[16], at[86]); MULADD(at[17], at[85]); MULADD(at[18], at[84]); MULADD(at[19], at[83]); MULADD(at[20], at[82]); MULADD(at[21], at[81]); MULADD(at[22], at[80]); MULADD(at[23], at[79]); MULADD(at[24], at[78]); MULADD(at[25], at[77]); MULADD(at[26], at[76]); MULADD(at[27], at[75]); MULADD(at[28], at[74]); MULADD(at[29], at[73]); MULADD(at[30], at[72]); MULADD(at[31], at[71]); MULADD(at[32], at[70]); MULADD(at[33], at[69]); MULADD(at[34], at[68]); MULADD(at[35], at[67]); MULADD(at[36], at[66]); MULADD(at[37], at[65]); MULADD(at[38], at[64]); MULADD(at[39], at[63]); MULADD(at[40], at[62]); MULADD(at[41], at[61]); MULADD(at[42], at[60]); MULADD(at[43], at[59]); MULADD(at[44], at[58]); MULADD(at[45], at[57]); MULADD(at[46], at[56]); MULADD(at[47], at[55]);
|
||||
COMBA_STORE(C->dp[54]);
|
||||
|
||||
/* early out at 56 digits, 56*32==1792, or two 896 bit operands */
|
||||
if (out_size <= 56) { COMBA_STORE2(C->dp[55]); C->used = 56; C->sign = A->sign ^ B->sign; fp_clamp(C); COMBA_FINI; return; }
|
||||
|
||||
/* 55 */
|
||||
COMBA_FORWARD;
|
||||
MULADD(at[8], at[95]); MULADD(at[9], at[94]); MULADD(at[10], at[93]); MULADD(at[11], at[92]); MULADD(at[12], at[91]); MULADD(at[13], at[90]); MULADD(at[14], at[89]); MULADD(at[15], at[88]); MULADD(at[16], at[87]); MULADD(at[17], at[86]); MULADD(at[18], at[85]); MULADD(at[19], at[84]); MULADD(at[20], at[83]); MULADD(at[21], at[82]); MULADD(at[22], at[81]); MULADD(at[23], at[80]); MULADD(at[24], at[79]); MULADD(at[25], at[78]); MULADD(at[26], at[77]); MULADD(at[27], at[76]); MULADD(at[28], at[75]); MULADD(at[29], at[74]); MULADD(at[30], at[73]); MULADD(at[31], at[72]); MULADD(at[32], at[71]); MULADD(at[33], at[70]); MULADD(at[34], at[69]); MULADD(at[35], at[68]); MULADD(at[36], at[67]); MULADD(at[37], at[66]); MULADD(at[38], at[65]); MULADD(at[39], at[64]); MULADD(at[40], at[63]); MULADD(at[41], at[62]); MULADD(at[42], at[61]); MULADD(at[43], at[60]); MULADD(at[44], at[59]); MULADD(at[45], at[58]); MULADD(at[46], at[57]); MULADD(at[47], at[56]);
|
||||
@ -280,10 +262,6 @@ void fp_mul_comba48(fp_int *A, fp_int *B, fp_int *C)
|
||||
COMBA_FORWARD;
|
||||
MULADD(at[15], at[95]); MULADD(at[16], at[94]); MULADD(at[17], at[93]); MULADD(at[18], at[92]); MULADD(at[19], at[91]); MULADD(at[20], at[90]); MULADD(at[21], at[89]); MULADD(at[22], at[88]); MULADD(at[23], at[87]); MULADD(at[24], at[86]); MULADD(at[25], at[85]); MULADD(at[26], at[84]); MULADD(at[27], at[83]); MULADD(at[28], at[82]); MULADD(at[29], at[81]); MULADD(at[30], at[80]); MULADD(at[31], at[79]); MULADD(at[32], at[78]); MULADD(at[33], at[77]); MULADD(at[34], at[76]); MULADD(at[35], at[75]); MULADD(at[36], at[74]); MULADD(at[37], at[73]); MULADD(at[38], at[72]); MULADD(at[39], at[71]); MULADD(at[40], at[70]); MULADD(at[41], at[69]); MULADD(at[42], at[68]); MULADD(at[43], at[67]); MULADD(at[44], at[66]); MULADD(at[45], at[65]); MULADD(at[46], at[64]); MULADD(at[47], at[63]);
|
||||
COMBA_STORE(C->dp[62]);
|
||||
|
||||
/* early out at 64 digits, 64*32==2048, or two 1024 bit operands */
|
||||
if (out_size <= 64) { COMBA_STORE2(C->dp[63]); C->used = 64; C->sign = A->sign ^ B->sign; fp_clamp(C); COMBA_FINI; return; }
|
||||
|
||||
/* 63 */
|
||||
COMBA_FORWARD;
|
||||
MULADD(at[16], at[95]); MULADD(at[17], at[94]); MULADD(at[18], at[93]); MULADD(at[19], at[92]); MULADD(at[20], at[91]); MULADD(at[21], at[90]); MULADD(at[22], at[89]); MULADD(at[23], at[88]); MULADD(at[24], at[87]); MULADD(at[25], at[86]); MULADD(at[26], at[85]); MULADD(at[27], at[84]); MULADD(at[28], at[83]); MULADD(at[29], at[82]); MULADD(at[30], at[81]); MULADD(at[31], at[80]); MULADD(at[32], at[79]); MULADD(at[33], at[78]); MULADD(at[34], at[77]); MULADD(at[35], at[76]); MULADD(at[36], at[75]); MULADD(at[37], at[74]); MULADD(at[38], at[73]); MULADD(at[39], at[72]); MULADD(at[40], at[71]); MULADD(at[41], at[70]); MULADD(at[42], at[69]); MULADD(at[43], at[68]); MULADD(at[44], at[67]); MULADD(at[45], at[66]); MULADD(at[46], at[65]); MULADD(at[47], at[64]);
|
||||
@ -316,10 +294,6 @@ void fp_mul_comba48(fp_int *A, fp_int *B, fp_int *C)
|
||||
COMBA_FORWARD;
|
||||
MULADD(at[23], at[95]); MULADD(at[24], at[94]); MULADD(at[25], at[93]); MULADD(at[26], at[92]); MULADD(at[27], at[91]); MULADD(at[28], at[90]); MULADD(at[29], at[89]); MULADD(at[30], at[88]); MULADD(at[31], at[87]); MULADD(at[32], at[86]); MULADD(at[33], at[85]); MULADD(at[34], at[84]); MULADD(at[35], at[83]); MULADD(at[36], at[82]); MULADD(at[37], at[81]); MULADD(at[38], at[80]); MULADD(at[39], at[79]); MULADD(at[40], at[78]); MULADD(at[41], at[77]); MULADD(at[42], at[76]); MULADD(at[43], at[75]); MULADD(at[44], at[74]); MULADD(at[45], at[73]); MULADD(at[46], at[72]); MULADD(at[47], at[71]);
|
||||
COMBA_STORE(C->dp[70]);
|
||||
|
||||
/* early out at 72 digits, 72*32==2304, or two 1152 bit operands */
|
||||
if (out_size <= 72) { COMBA_STORE2(C->dp[71]); C->used = 72; C->sign = A->sign ^ B->sign; fp_clamp(C); COMBA_FINI; return; }
|
||||
|
||||
/* 71 */
|
||||
COMBA_FORWARD;
|
||||
MULADD(at[24], at[95]); MULADD(at[25], at[94]); MULADD(at[26], at[93]); MULADD(at[27], at[92]); MULADD(at[28], at[91]); MULADD(at[29], at[90]); MULADD(at[30], at[89]); MULADD(at[31], at[88]); MULADD(at[32], at[87]); MULADD(at[33], at[86]); MULADD(at[34], at[85]); MULADD(at[35], at[84]); MULADD(at[36], at[83]); MULADD(at[37], at[82]); MULADD(at[38], at[81]); MULADD(at[39], at[80]); MULADD(at[40], at[79]); MULADD(at[41], at[78]); MULADD(at[42], at[77]); MULADD(at[43], at[76]); MULADD(at[44], at[75]); MULADD(at[45], at[74]); MULADD(at[46], at[73]); MULADD(at[47], at[72]);
|
||||
@ -352,10 +326,6 @@ void fp_mul_comba48(fp_int *A, fp_int *B, fp_int *C)
|
||||
COMBA_FORWARD;
|
||||
MULADD(at[31], at[95]); MULADD(at[32], at[94]); MULADD(at[33], at[93]); MULADD(at[34], at[92]); MULADD(at[35], at[91]); MULADD(at[36], at[90]); MULADD(at[37], at[89]); MULADD(at[38], at[88]); MULADD(at[39], at[87]); MULADD(at[40], at[86]); MULADD(at[41], at[85]); MULADD(at[42], at[84]); MULADD(at[43], at[83]); MULADD(at[44], at[82]); MULADD(at[45], at[81]); MULADD(at[46], at[80]); MULADD(at[47], at[79]);
|
||||
COMBA_STORE(C->dp[78]);
|
||||
|
||||
/* early out at 80 digits, 80*32==2560, or two 1280 bit operands */
|
||||
if (out_size <= 80) { COMBA_STORE2(C->dp[79]); C->used = 80; C->sign = A->sign ^ B->sign; fp_clamp(C); COMBA_FINI; return; }
|
||||
|
||||
/* 79 */
|
||||
COMBA_FORWARD;
|
||||
MULADD(at[32], at[95]); MULADD(at[33], at[94]); MULADD(at[34], at[93]); MULADD(at[35], at[92]); MULADD(at[36], at[91]); MULADD(at[37], at[90]); MULADD(at[38], at[89]); MULADD(at[39], at[88]); MULADD(at[40], at[87]); MULADD(at[41], at[86]); MULADD(at[42], at[85]); MULADD(at[43], at[84]); MULADD(at[44], at[83]); MULADD(at[45], at[82]); MULADD(at[46], at[81]); MULADD(at[47], at[80]);
|
||||
@ -388,10 +358,6 @@ void fp_mul_comba48(fp_int *A, fp_int *B, fp_int *C)
|
||||
COMBA_FORWARD;
|
||||
MULADD(at[39], at[95]); MULADD(at[40], at[94]); MULADD(at[41], at[93]); MULADD(at[42], at[92]); MULADD(at[43], at[91]); MULADD(at[44], at[90]); MULADD(at[45], at[89]); MULADD(at[46], at[88]); MULADD(at[47], at[87]);
|
||||
COMBA_STORE(C->dp[86]);
|
||||
|
||||
/* early out at 88 digits, 88*32==2816, or two 1408 bit operands */
|
||||
if (out_size <= 88) { COMBA_STORE2(C->dp[87]); C->used = 88; C->sign = A->sign ^ B->sign; fp_clamp(C); COMBA_FINI; return; }
|
||||
|
||||
/* 87 */
|
||||
COMBA_FORWARD;
|
||||
MULADD(at[40], at[95]); MULADD(at[41], at[94]); MULADD(at[42], at[93]); MULADD(at[43], at[92]); MULADD(at[44], at[91]); MULADD(at[45], at[90]); MULADD(at[46], at[89]); MULADD(at[47], at[88]);
|
||||
@ -431,3 +397,8 @@ void fp_mul_comba48(fp_int *A, fp_int *B, fp_int *C)
|
||||
COMBA_FINI;
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
/* $Source$ */
|
||||
/* $Revision$ */
|
||||
/* $Date$ */
|
||||
|
@ -1,9 +1,5 @@
|
||||
/* TomsFastMath, a fast ISO C bignum library. -- Tom St Denis */
|
||||
/* SPDX-License-Identifier: Unlicense */
|
||||
#ifndef TFM_PRE_GEN_MPI_C
|
||||
#define TFM_DEFINES
|
||||
#include "fp_mul_comba.c"
|
||||
#endif
|
||||
|
||||
#if defined(TFM_MUL6) && FP_SIZE >= 12
|
||||
void fp_mul_comba6(fp_int *A, fp_int *B, fp_int *C)
|
||||
@ -65,3 +61,8 @@ void fp_mul_comba6(fp_int *A, fp_int *B, fp_int *C)
|
||||
COMBA_FINI;
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
/* $Source$ */
|
||||
/* $Revision$ */
|
||||
/* $Date$ */
|
||||
|
@ -1,17 +1,11 @@
|
||||
/* TomsFastMath, a fast ISO C bignum library. -- Tom St Denis */
|
||||
/* SPDX-License-Identifier: Unlicense */
|
||||
#ifndef TFM_PRE_GEN_MPI_C
|
||||
#define TFM_DEFINES
|
||||
#include "fp_mul_comba.c"
|
||||
#endif
|
||||
|
||||
#if defined(TFM_MUL64) && FP_SIZE >= 128
|
||||
void fp_mul_comba64(fp_int *A, fp_int *B, fp_int *C)
|
||||
{
|
||||
fp_digit c0, c1, c2, at[128];
|
||||
int out_size;
|
||||
|
||||
out_size = A->used + B->used;
|
||||
memcpy(at, A->dp, 64 * sizeof(fp_digit));
|
||||
memcpy(at+64, B->dp, 64 * sizeof(fp_digit));
|
||||
COMBA_START;
|
||||
@ -172,10 +166,6 @@ void fp_mul_comba64(fp_int *A, fp_int *B, fp_int *C)
|
||||
COMBA_FORWARD;
|
||||
MULADD(at[0], at[102]); MULADD(at[1], at[101]); MULADD(at[2], at[100]); MULADD(at[3], at[99]); MULADD(at[4], at[98]); MULADD(at[5], at[97]); MULADD(at[6], at[96]); MULADD(at[7], at[95]); MULADD(at[8], at[94]); MULADD(at[9], at[93]); MULADD(at[10], at[92]); MULADD(at[11], at[91]); MULADD(at[12], at[90]); MULADD(at[13], at[89]); MULADD(at[14], at[88]); MULADD(at[15], at[87]); MULADD(at[16], at[86]); MULADD(at[17], at[85]); MULADD(at[18], at[84]); MULADD(at[19], at[83]); MULADD(at[20], at[82]); MULADD(at[21], at[81]); MULADD(at[22], at[80]); MULADD(at[23], at[79]); MULADD(at[24], at[78]); MULADD(at[25], at[77]); MULADD(at[26], at[76]); MULADD(at[27], at[75]); MULADD(at[28], at[74]); MULADD(at[29], at[73]); MULADD(at[30], at[72]); MULADD(at[31], at[71]); MULADD(at[32], at[70]); MULADD(at[33], at[69]); MULADD(at[34], at[68]); MULADD(at[35], at[67]); MULADD(at[36], at[66]); MULADD(at[37], at[65]); MULADD(at[38], at[64]);
|
||||
COMBA_STORE(C->dp[38]);
|
||||
|
||||
/* early out at 40 digits, 40*32==1280, or two 640 bit operands */
|
||||
if (out_size <= 40) { COMBA_STORE2(C->dp[39]); C->used = 40; C->sign = A->sign ^ B->sign; fp_clamp(C); COMBA_FINI; return; }
|
||||
|
||||
/* 39 */
|
||||
COMBA_FORWARD;
|
||||
MULADD(at[0], at[103]); MULADD(at[1], at[102]); MULADD(at[2], at[101]); MULADD(at[3], at[100]); MULADD(at[4], at[99]); MULADD(at[5], at[98]); MULADD(at[6], at[97]); MULADD(at[7], at[96]); MULADD(at[8], at[95]); MULADD(at[9], at[94]); MULADD(at[10], at[93]); MULADD(at[11], at[92]); MULADD(at[12], at[91]); MULADD(at[13], at[90]); MULADD(at[14], at[89]); MULADD(at[15], at[88]); MULADD(at[16], at[87]); MULADD(at[17], at[86]); MULADD(at[18], at[85]); MULADD(at[19], at[84]); MULADD(at[20], at[83]); MULADD(at[21], at[82]); MULADD(at[22], at[81]); MULADD(at[23], at[80]); MULADD(at[24], at[79]); MULADD(at[25], at[78]); MULADD(at[26], at[77]); MULADD(at[27], at[76]); MULADD(at[28], at[75]); MULADD(at[29], at[74]); MULADD(at[30], at[73]); MULADD(at[31], at[72]); MULADD(at[32], at[71]); MULADD(at[33], at[70]); MULADD(at[34], at[69]); MULADD(at[35], at[68]); MULADD(at[36], at[67]); MULADD(at[37], at[66]); MULADD(at[38], at[65]); MULADD(at[39], at[64]);
|
||||
@ -208,10 +198,6 @@ void fp_mul_comba64(fp_int *A, fp_int *B, fp_int *C)
|
||||
COMBA_FORWARD;
|
||||
MULADD(at[0], at[110]); MULADD(at[1], at[109]); MULADD(at[2], at[108]); MULADD(at[3], at[107]); MULADD(at[4], at[106]); MULADD(at[5], at[105]); MULADD(at[6], at[104]); MULADD(at[7], at[103]); MULADD(at[8], at[102]); MULADD(at[9], at[101]); MULADD(at[10], at[100]); MULADD(at[11], at[99]); MULADD(at[12], at[98]); MULADD(at[13], at[97]); MULADD(at[14], at[96]); MULADD(at[15], at[95]); MULADD(at[16], at[94]); MULADD(at[17], at[93]); MULADD(at[18], at[92]); MULADD(at[19], at[91]); MULADD(at[20], at[90]); MULADD(at[21], at[89]); MULADD(at[22], at[88]); MULADD(at[23], at[87]); MULADD(at[24], at[86]); MULADD(at[25], at[85]); MULADD(at[26], at[84]); MULADD(at[27], at[83]); MULADD(at[28], at[82]); MULADD(at[29], at[81]); MULADD(at[30], at[80]); MULADD(at[31], at[79]); MULADD(at[32], at[78]); MULADD(at[33], at[77]); MULADD(at[34], at[76]); MULADD(at[35], at[75]); MULADD(at[36], at[74]); MULADD(at[37], at[73]); MULADD(at[38], at[72]); MULADD(at[39], at[71]); MULADD(at[40], at[70]); MULADD(at[41], at[69]); MULADD(at[42], at[68]); MULADD(at[43], at[67]); MULADD(at[44], at[66]); MULADD(at[45], at[65]); MULADD(at[46], at[64]);
|
||||
COMBA_STORE(C->dp[46]);
|
||||
|
||||
/* early out at 48 digits, 48*32==1536, or two 768 bit operands */
|
||||
if (out_size <= 48) { COMBA_STORE2(C->dp[47]); C->used = 48; C->sign = A->sign ^ B->sign; fp_clamp(C); COMBA_FINI; return; }
|
||||
|
||||
/* 47 */
|
||||
COMBA_FORWARD;
|
||||
MULADD(at[0], at[111]); MULADD(at[1], at[110]); MULADD(at[2], at[109]); MULADD(at[3], at[108]); MULADD(at[4], at[107]); MULADD(at[5], at[106]); MULADD(at[6], at[105]); MULADD(at[7], at[104]); MULADD(at[8], at[103]); MULADD(at[9], at[102]); MULADD(at[10], at[101]); MULADD(at[11], at[100]); MULADD(at[12], at[99]); MULADD(at[13], at[98]); MULADD(at[14], at[97]); MULADD(at[15], at[96]); MULADD(at[16], at[95]); MULADD(at[17], at[94]); MULADD(at[18], at[93]); MULADD(at[19], at[92]); MULADD(at[20], at[91]); MULADD(at[21], at[90]); MULADD(at[22], at[89]); MULADD(at[23], at[88]); MULADD(at[24], at[87]); MULADD(at[25], at[86]); MULADD(at[26], at[85]); MULADD(at[27], at[84]); MULADD(at[28], at[83]); MULADD(at[29], at[82]); MULADD(at[30], at[81]); MULADD(at[31], at[80]); MULADD(at[32], at[79]); MULADD(at[33], at[78]); MULADD(at[34], at[77]); MULADD(at[35], at[76]); MULADD(at[36], at[75]); MULADD(at[37], at[74]); MULADD(at[38], at[73]); MULADD(at[39], at[72]); MULADD(at[40], at[71]); MULADD(at[41], at[70]); MULADD(at[42], at[69]); MULADD(at[43], at[68]); MULADD(at[44], at[67]); MULADD(at[45], at[66]); MULADD(at[46], at[65]); MULADD(at[47], at[64]);
|
||||
@ -244,10 +230,6 @@ void fp_mul_comba64(fp_int *A, fp_int *B, fp_int *C)
|
||||
COMBA_FORWARD;
|
||||
MULADD(at[0], at[118]); MULADD(at[1], at[117]); MULADD(at[2], at[116]); MULADD(at[3], at[115]); MULADD(at[4], at[114]); MULADD(at[5], at[113]); MULADD(at[6], at[112]); MULADD(at[7], at[111]); MULADD(at[8], at[110]); MULADD(at[9], at[109]); MULADD(at[10], at[108]); MULADD(at[11], at[107]); MULADD(at[12], at[106]); MULADD(at[13], at[105]); MULADD(at[14], at[104]); MULADD(at[15], at[103]); MULADD(at[16], at[102]); MULADD(at[17], at[101]); MULADD(at[18], at[100]); MULADD(at[19], at[99]); MULADD(at[20], at[98]); MULADD(at[21], at[97]); MULADD(at[22], at[96]); MULADD(at[23], at[95]); MULADD(at[24], at[94]); MULADD(at[25], at[93]); MULADD(at[26], at[92]); MULADD(at[27], at[91]); MULADD(at[28], at[90]); MULADD(at[29], at[89]); MULADD(at[30], at[88]); MULADD(at[31], at[87]); MULADD(at[32], at[86]); MULADD(at[33], at[85]); MULADD(at[34], at[84]); MULADD(at[35], at[83]); MULADD(at[36], at[82]); MULADD(at[37], at[81]); MULADD(at[38], at[80]); MULADD(at[39], at[79]); MULADD(at[40], at[78]); MULADD(at[41], at[77]); MULADD(at[42], at[76]); MULADD(at[43], at[75]); MULADD(at[44], at[74]); MULADD(at[45], at[73]); MULADD(at[46], at[72]); MULADD(at[47], at[71]); MULADD(at[48], at[70]); MULADD(at[49], at[69]); MULADD(at[50], at[68]); MULADD(at[51], at[67]); MULADD(at[52], at[66]); MULADD(at[53], at[65]); MULADD(at[54], at[64]);
|
||||
COMBA_STORE(C->dp[54]);
|
||||
|
||||
/* early out at 56 digits, 56*32==1792, or two 896 bit operands */
|
||||
if (out_size <= 56) { COMBA_STORE2(C->dp[55]); C->used = 56; C->sign = A->sign ^ B->sign; fp_clamp(C); COMBA_FINI; return; }
|
||||
|
||||
/* 55 */
|
||||
COMBA_FORWARD;
|
||||
MULADD(at[0], at[119]); MULADD(at[1], at[118]); MULADD(at[2], at[117]); MULADD(at[3], at[116]); MULADD(at[4], at[115]); MULADD(at[5], at[114]); MULADD(at[6], at[113]); MULADD(at[7], at[112]); MULADD(at[8], at[111]); MULADD(at[9], at[110]); MULADD(at[10], at[109]); MULADD(at[11], at[108]); MULADD(at[12], at[107]); MULADD(at[13], at[106]); MULADD(at[14], at[105]); MULADD(at[15], at[104]); MULADD(at[16], at[103]); MULADD(at[17], at[102]); MULADD(at[18], at[101]); MULADD(at[19], at[100]); MULADD(at[20], at[99]); MULADD(at[21], at[98]); MULADD(at[22], at[97]); MULADD(at[23], at[96]); MULADD(at[24], at[95]); MULADD(at[25], at[94]); MULADD(at[26], at[93]); MULADD(at[27], at[92]); MULADD(at[28], at[91]); MULADD(at[29], at[90]); MULADD(at[30], at[89]); MULADD(at[31], at[88]); MULADD(at[32], at[87]); MULADD(at[33], at[86]); MULADD(at[34], at[85]); MULADD(at[35], at[84]); MULADD(at[36], at[83]); MULADD(at[37], at[82]); MULADD(at[38], at[81]); MULADD(at[39], at[80]); MULADD(at[40], at[79]); MULADD(at[41], at[78]); MULADD(at[42], at[77]); MULADD(at[43], at[76]); MULADD(at[44], at[75]); MULADD(at[45], at[74]); MULADD(at[46], at[73]); MULADD(at[47], at[72]); MULADD(at[48], at[71]); MULADD(at[49], at[70]); MULADD(at[50], at[69]); MULADD(at[51], at[68]); MULADD(at[52], at[67]); MULADD(at[53], at[66]); MULADD(at[54], at[65]); MULADD(at[55], at[64]);
|
||||
@ -280,10 +262,6 @@ void fp_mul_comba64(fp_int *A, fp_int *B, fp_int *C)
|
||||
COMBA_FORWARD;
|
||||
MULADD(at[0], at[126]); MULADD(at[1], at[125]); MULADD(at[2], at[124]); MULADD(at[3], at[123]); MULADD(at[4], at[122]); MULADD(at[5], at[121]); MULADD(at[6], at[120]); MULADD(at[7], at[119]); MULADD(at[8], at[118]); MULADD(at[9], at[117]); MULADD(at[10], at[116]); MULADD(at[11], at[115]); MULADD(at[12], at[114]); MULADD(at[13], at[113]); MULADD(at[14], at[112]); MULADD(at[15], at[111]); MULADD(at[16], at[110]); MULADD(at[17], at[109]); MULADD(at[18], at[108]); MULADD(at[19], at[107]); MULADD(at[20], at[106]); MULADD(at[21], at[105]); MULADD(at[22], at[104]); MULADD(at[23], at[103]); MULADD(at[24], at[102]); MULADD(at[25], at[101]); MULADD(at[26], at[100]); MULADD(at[27], at[99]); MULADD(at[28], at[98]); MULADD(at[29], at[97]); MULADD(at[30], at[96]); MULADD(at[31], at[95]); MULADD(at[32], at[94]); MULADD(at[33], at[93]); MULADD(at[34], at[92]); MULADD(at[35], at[91]); MULADD(at[36], at[90]); MULADD(at[37], at[89]); MULADD(at[38], at[88]); MULADD(at[39], at[87]); MULADD(at[40], at[86]); MULADD(at[41], at[85]); MULADD(at[42], at[84]); MULADD(at[43], at[83]); MULADD(at[44], at[82]); MULADD(at[45], at[81]); MULADD(at[46], at[80]); MULADD(at[47], at[79]); MULADD(at[48], at[78]); MULADD(at[49], at[77]); MULADD(at[50], at[76]); MULADD(at[51], at[75]); MULADD(at[52], at[74]); MULADD(at[53], at[73]); MULADD(at[54], at[72]); MULADD(at[55], at[71]); MULADD(at[56], at[70]); MULADD(at[57], at[69]); MULADD(at[58], at[68]); MULADD(at[59], at[67]); MULADD(at[60], at[66]); MULADD(at[61], at[65]); MULADD(at[62], at[64]);
|
||||
COMBA_STORE(C->dp[62]);
|
||||
|
||||
/* early out at 64 digits, 64*32==2048, or two 1024 bit operands */
|
||||
if (out_size <= 64) { COMBA_STORE2(C->dp[63]); C->used = 64; C->sign = A->sign ^ B->sign; fp_clamp(C); COMBA_FINI; return; }
|
||||
|
||||
/* 63 */
|
||||
COMBA_FORWARD;
|
||||
MULADD(at[0], at[127]); MULADD(at[1], at[126]); MULADD(at[2], at[125]); MULADD(at[3], at[124]); MULADD(at[4], at[123]); MULADD(at[5], at[122]); MULADD(at[6], at[121]); MULADD(at[7], at[120]); MULADD(at[8], at[119]); MULADD(at[9], at[118]); MULADD(at[10], at[117]); MULADD(at[11], at[116]); MULADD(at[12], at[115]); MULADD(at[13], at[114]); MULADD(at[14], at[113]); MULADD(at[15], at[112]); MULADD(at[16], at[111]); MULADD(at[17], at[110]); MULADD(at[18], at[109]); MULADD(at[19], at[108]); MULADD(at[20], at[107]); MULADD(at[21], at[106]); MULADD(at[22], at[105]); MULADD(at[23], at[104]); MULADD(at[24], at[103]); MULADD(at[25], at[102]); MULADD(at[26], at[101]); MULADD(at[27], at[100]); MULADD(at[28], at[99]); MULADD(at[29], at[98]); MULADD(at[30], at[97]); MULADD(at[31], at[96]); MULADD(at[32], at[95]); MULADD(at[33], at[94]); MULADD(at[34], at[93]); MULADD(at[35], at[92]); MULADD(at[36], at[91]); MULADD(at[37], at[90]); MULADD(at[38], at[89]); MULADD(at[39], at[88]); MULADD(at[40], at[87]); MULADD(at[41], at[86]); MULADD(at[42], at[85]); MULADD(at[43], at[84]); MULADD(at[44], at[83]); MULADD(at[45], at[82]); MULADD(at[46], at[81]); MULADD(at[47], at[80]); MULADD(at[48], at[79]); MULADD(at[49], at[78]); MULADD(at[50], at[77]); MULADD(at[51], at[76]); MULADD(at[52], at[75]); MULADD(at[53], at[74]); MULADD(at[54], at[73]); MULADD(at[55], at[72]); MULADD(at[56], at[71]); MULADD(at[57], at[70]); MULADD(at[58], at[69]); MULADD(at[59], at[68]); MULADD(at[60], at[67]); MULADD(at[61], at[66]); MULADD(at[62], at[65]); MULADD(at[63], at[64]);
|
||||
@ -316,10 +294,6 @@ void fp_mul_comba64(fp_int *A, fp_int *B, fp_int *C)
|
||||
COMBA_FORWARD;
|
||||
MULADD(at[7], at[127]); MULADD(at[8], at[126]); MULADD(at[9], at[125]); MULADD(at[10], at[124]); MULADD(at[11], at[123]); MULADD(at[12], at[122]); MULADD(at[13], at[121]); MULADD(at[14], at[120]); MULADD(at[15], at[119]); MULADD(at[16], at[118]); MULADD(at[17], at[117]); MULADD(at[18], at[116]); MULADD(at[19], at[115]); MULADD(at[20], at[114]); MULADD(at[21], at[113]); MULADD(at[22], at[112]); MULADD(at[23], at[111]); MULADD(at[24], at[110]); MULADD(at[25], at[109]); MULADD(at[26], at[108]); MULADD(at[27], at[107]); MULADD(at[28], at[106]); MULADD(at[29], at[105]); MULADD(at[30], at[104]); MULADD(at[31], at[103]); MULADD(at[32], at[102]); MULADD(at[33], at[101]); MULADD(at[34], at[100]); MULADD(at[35], at[99]); MULADD(at[36], at[98]); MULADD(at[37], at[97]); MULADD(at[38], at[96]); MULADD(at[39], at[95]); MULADD(at[40], at[94]); MULADD(at[41], at[93]); MULADD(at[42], at[92]); MULADD(at[43], at[91]); MULADD(at[44], at[90]); MULADD(at[45], at[89]); MULADD(at[46], at[88]); MULADD(at[47], at[87]); MULADD(at[48], at[86]); MULADD(at[49], at[85]); MULADD(at[50], at[84]); MULADD(at[51], at[83]); MULADD(at[52], at[82]); MULADD(at[53], at[81]); MULADD(at[54], at[80]); MULADD(at[55], at[79]); MULADD(at[56], at[78]); MULADD(at[57], at[77]); MULADD(at[58], at[76]); MULADD(at[59], at[75]); MULADD(at[60], at[74]); MULADD(at[61], at[73]); MULADD(at[62], at[72]); MULADD(at[63], at[71]);
|
||||
COMBA_STORE(C->dp[70]);
|
||||
|
||||
/* early out at 72 digits, 72*32==2304, or two 1152 bit operands */
|
||||
if (out_size <= 72) { COMBA_STORE2(C->dp[71]); C->used = 72; C->sign = A->sign ^ B->sign; fp_clamp(C); COMBA_FINI; return; }
|
||||
|
||||
/* 71 */
|
||||
COMBA_FORWARD;
|
||||
MULADD(at[8], at[127]); MULADD(at[9], at[126]); MULADD(at[10], at[125]); MULADD(at[11], at[124]); MULADD(at[12], at[123]); MULADD(at[13], at[122]); MULADD(at[14], at[121]); MULADD(at[15], at[120]); MULADD(at[16], at[119]); MULADD(at[17], at[118]); MULADD(at[18], at[117]); MULADD(at[19], at[116]); MULADD(at[20], at[115]); MULADD(at[21], at[114]); MULADD(at[22], at[113]); MULADD(at[23], at[112]); MULADD(at[24], at[111]); MULADD(at[25], at[110]); MULADD(at[26], at[109]); MULADD(at[27], at[108]); MULADD(at[28], at[107]); MULADD(at[29], at[106]); MULADD(at[30], at[105]); MULADD(at[31], at[104]); MULADD(at[32], at[103]); MULADD(at[33], at[102]); MULADD(at[34], at[101]); MULADD(at[35], at[100]); MULADD(at[36], at[99]); MULADD(at[37], at[98]); MULADD(at[38], at[97]); MULADD(at[39], at[96]); MULADD(at[40], at[95]); MULADD(at[41], at[94]); MULADD(at[42], at[93]); MULADD(at[43], at[92]); MULADD(at[44], at[91]); MULADD(at[45], at[90]); MULADD(at[46], at[89]); MULADD(at[47], at[88]); MULADD(at[48], at[87]); MULADD(at[49], at[86]); MULADD(at[50], at[85]); MULADD(at[51], at[84]); MULADD(at[52], at[83]); MULADD(at[53], at[82]); MULADD(at[54], at[81]); MULADD(at[55], at[80]); MULADD(at[56], at[79]); MULADD(at[57], at[78]); MULADD(at[58], at[77]); MULADD(at[59], at[76]); MULADD(at[60], at[75]); MULADD(at[61], at[74]); MULADD(at[62], at[73]); MULADD(at[63], at[72]);
|
||||
@ -352,10 +326,6 @@ void fp_mul_comba64(fp_int *A, fp_int *B, fp_int *C)
|
||||
COMBA_FORWARD;
|
||||
MULADD(at[15], at[127]); MULADD(at[16], at[126]); MULADD(at[17], at[125]); MULADD(at[18], at[124]); MULADD(at[19], at[123]); MULADD(at[20], at[122]); MULADD(at[21], at[121]); MULADD(at[22], at[120]); MULADD(at[23], at[119]); MULADD(at[24], at[118]); MULADD(at[25], at[117]); MULADD(at[26], at[116]); MULADD(at[27], at[115]); MULADD(at[28], at[114]); MULADD(at[29], at[113]); MULADD(at[30], at[112]); MULADD(at[31], at[111]); MULADD(at[32], at[110]); MULADD(at[33], at[109]); MULADD(at[34], at[108]); MULADD(at[35], at[107]); MULADD(at[36], at[106]); MULADD(at[37], at[105]); MULADD(at[38], at[104]); MULADD(at[39], at[103]); MULADD(at[40], at[102]); MULADD(at[41], at[101]); MULADD(at[42], at[100]); MULADD(at[43], at[99]); MULADD(at[44], at[98]); MULADD(at[45], at[97]); MULADD(at[46], at[96]); MULADD(at[47], at[95]); MULADD(at[48], at[94]); MULADD(at[49], at[93]); MULADD(at[50], at[92]); MULADD(at[51], at[91]); MULADD(at[52], at[90]); MULADD(at[53], at[89]); MULADD(at[54], at[88]); MULADD(at[55], at[87]); MULADD(at[56], at[86]); MULADD(at[57], at[85]); MULADD(at[58], at[84]); MULADD(at[59], at[83]); MULADD(at[60], at[82]); MULADD(at[61], at[81]); MULADD(at[62], at[80]); MULADD(at[63], at[79]);
|
||||
COMBA_STORE(C->dp[78]);
|
||||
|
||||
/* early out at 80 digits, 80*32==2560, or two 1280 bit operands */
|
||||
if (out_size <= 80) { COMBA_STORE2(C->dp[79]); C->used = 80; C->sign = A->sign ^ B->sign; fp_clamp(C); COMBA_FINI; return; }
|
||||
|
||||
/* 79 */
|
||||
COMBA_FORWARD;
|
||||
MULADD(at[16], at[127]); MULADD(at[17], at[126]); MULADD(at[18], at[125]); MULADD(at[19], at[124]); MULADD(at[20], at[123]); MULADD(at[21], at[122]); MULADD(at[22], at[121]); MULADD(at[23], at[120]); MULADD(at[24], at[119]); MULADD(at[25], at[118]); MULADD(at[26], at[117]); MULADD(at[27], at[116]); MULADD(at[28], at[115]); MULADD(at[29], at[114]); MULADD(at[30], at[113]); MULADD(at[31], at[112]); MULADD(at[32], at[111]); MULADD(at[33], at[110]); MULADD(at[34], at[109]); MULADD(at[35], at[108]); MULADD(at[36], at[107]); MULADD(at[37], at[106]); MULADD(at[38], at[105]); MULADD(at[39], at[104]); MULADD(at[40], at[103]); MULADD(at[41], at[102]); MULADD(at[42], at[101]); MULADD(at[43], at[100]); MULADD(at[44], at[99]); MULADD(at[45], at[98]); MULADD(at[46], at[97]); MULADD(at[47], at[96]); MULADD(at[48], at[95]); MULADD(at[49], at[94]); MULADD(at[50], at[93]); MULADD(at[51], at[92]); MULADD(at[52], at[91]); MULADD(at[53], at[90]); MULADD(at[54], at[89]); MULADD(at[55], at[88]); MULADD(at[56], at[87]); MULADD(at[57], at[86]); MULADD(at[58], at[85]); MULADD(at[59], at[84]); MULADD(at[60], at[83]); MULADD(at[61], at[82]); MULADD(at[62], at[81]); MULADD(at[63], at[80]);
|
||||
@ -388,10 +358,6 @@ void fp_mul_comba64(fp_int *A, fp_int *B, fp_int *C)
|
||||
COMBA_FORWARD;
|
||||
MULADD(at[23], at[127]); MULADD(at[24], at[126]); MULADD(at[25], at[125]); MULADD(at[26], at[124]); MULADD(at[27], at[123]); MULADD(at[28], at[122]); MULADD(at[29], at[121]); MULADD(at[30], at[120]); MULADD(at[31], at[119]); MULADD(at[32], at[118]); MULADD(at[33], at[117]); MULADD(at[34], at[116]); MULADD(at[35], at[115]); MULADD(at[36], at[114]); MULADD(at[37], at[113]); MULADD(at[38], at[112]); MULADD(at[39], at[111]); MULADD(at[40], at[110]); MULADD(at[41], at[109]); MULADD(at[42], at[108]); MULADD(at[43], at[107]); MULADD(at[44], at[106]); MULADD(at[45], at[105]); MULADD(at[46], at[104]); MULADD(at[47], at[103]); MULADD(at[48], at[102]); MULADD(at[49], at[101]); MULADD(at[50], at[100]); MULADD(at[51], at[99]); MULADD(at[52], at[98]); MULADD(at[53], at[97]); MULADD(at[54], at[96]); MULADD(at[55], at[95]); MULADD(at[56], at[94]); MULADD(at[57], at[93]); MULADD(at[58], at[92]); MULADD(at[59], at[91]); MULADD(at[60], at[90]); MULADD(at[61], at[89]); MULADD(at[62], at[88]); MULADD(at[63], at[87]);
|
||||
COMBA_STORE(C->dp[86]);
|
||||
|
||||
/* early out at 88 digits, 88*32==2816, or two 1408 bit operands */
|
||||
if (out_size <= 88) { COMBA_STORE2(C->dp[87]); C->used = 88; C->sign = A->sign ^ B->sign; fp_clamp(C); COMBA_FINI; return; }
|
||||
|
||||
/* 87 */
|
||||
COMBA_FORWARD;
|
||||
MULADD(at[24], at[127]); MULADD(at[25], at[126]); MULADD(at[26], at[125]); MULADD(at[27], at[124]); MULADD(at[28], at[123]); MULADD(at[29], at[122]); MULADD(at[30], at[121]); MULADD(at[31], at[120]); MULADD(at[32], at[119]); MULADD(at[33], at[118]); MULADD(at[34], at[117]); MULADD(at[35], at[116]); MULADD(at[36], at[115]); MULADD(at[37], at[114]); MULADD(at[38], at[113]); MULADD(at[39], at[112]); MULADD(at[40], at[111]); MULADD(at[41], at[110]); MULADD(at[42], at[109]); MULADD(at[43], at[108]); MULADD(at[44], at[107]); MULADD(at[45], at[106]); MULADD(at[46], at[105]); MULADD(at[47], at[104]); MULADD(at[48], at[103]); MULADD(at[49], at[102]); MULADD(at[50], at[101]); MULADD(at[51], at[100]); MULADD(at[52], at[99]); MULADD(at[53], at[98]); MULADD(at[54], at[97]); MULADD(at[55], at[96]); MULADD(at[56], at[95]); MULADD(at[57], at[94]); MULADD(at[58], at[93]); MULADD(at[59], at[92]); MULADD(at[60], at[91]); MULADD(at[61], at[90]); MULADD(at[62], at[89]); MULADD(at[63], at[88]);
|
||||
@ -424,10 +390,6 @@ void fp_mul_comba64(fp_int *A, fp_int *B, fp_int *C)
|
||||
COMBA_FORWARD;
|
||||
MULADD(at[31], at[127]); MULADD(at[32], at[126]); MULADD(at[33], at[125]); MULADD(at[34], at[124]); MULADD(at[35], at[123]); MULADD(at[36], at[122]); MULADD(at[37], at[121]); MULADD(at[38], at[120]); MULADD(at[39], at[119]); MULADD(at[40], at[118]); MULADD(at[41], at[117]); MULADD(at[42], at[116]); MULADD(at[43], at[115]); MULADD(at[44], at[114]); MULADD(at[45], at[113]); MULADD(at[46], at[112]); MULADD(at[47], at[111]); MULADD(at[48], at[110]); MULADD(at[49], at[109]); MULADD(at[50], at[108]); MULADD(at[51], at[107]); MULADD(at[52], at[106]); MULADD(at[53], at[105]); MULADD(at[54], at[104]); MULADD(at[55], at[103]); MULADD(at[56], at[102]); MULADD(at[57], at[101]); MULADD(at[58], at[100]); MULADD(at[59], at[99]); MULADD(at[60], at[98]); MULADD(at[61], at[97]); MULADD(at[62], at[96]); MULADD(at[63], at[95]);
|
||||
COMBA_STORE(C->dp[94]);
|
||||
|
||||
/* early out at 96 digits, 96*32==3072, or two 1536 bit operands */
|
||||
if (out_size <= 96) { COMBA_STORE2(C->dp[95]); C->used = 96; C->sign = A->sign ^ B->sign; fp_clamp(C); COMBA_FINI; return; }
|
||||
|
||||
/* 95 */
|
||||
COMBA_FORWARD;
|
||||
MULADD(at[32], at[127]); MULADD(at[33], at[126]); MULADD(at[34], at[125]); MULADD(at[35], at[124]); MULADD(at[36], at[123]); MULADD(at[37], at[122]); MULADD(at[38], at[121]); MULADD(at[39], at[120]); MULADD(at[40], at[119]); MULADD(at[41], at[118]); MULADD(at[42], at[117]); MULADD(at[43], at[116]); MULADD(at[44], at[115]); MULADD(at[45], at[114]); MULADD(at[46], at[113]); MULADD(at[47], at[112]); MULADD(at[48], at[111]); MULADD(at[49], at[110]); MULADD(at[50], at[109]); MULADD(at[51], at[108]); MULADD(at[52], at[107]); MULADD(at[53], at[106]); MULADD(at[54], at[105]); MULADD(at[55], at[104]); MULADD(at[56], at[103]); MULADD(at[57], at[102]); MULADD(at[58], at[101]); MULADD(at[59], at[100]); MULADD(at[60], at[99]); MULADD(at[61], at[98]); MULADD(at[62], at[97]); MULADD(at[63], at[96]);
|
||||
@ -460,10 +422,6 @@ void fp_mul_comba64(fp_int *A, fp_int *B, fp_int *C)
|
||||
COMBA_FORWARD;
|
||||
MULADD(at[39], at[127]); MULADD(at[40], at[126]); MULADD(at[41], at[125]); MULADD(at[42], at[124]); MULADD(at[43], at[123]); MULADD(at[44], at[122]); MULADD(at[45], at[121]); MULADD(at[46], at[120]); MULADD(at[47], at[119]); MULADD(at[48], at[118]); MULADD(at[49], at[117]); MULADD(at[50], at[116]); MULADD(at[51], at[115]); MULADD(at[52], at[114]); MULADD(at[53], at[113]); MULADD(at[54], at[112]); MULADD(at[55], at[111]); MULADD(at[56], at[110]); MULADD(at[57], at[109]); MULADD(at[58], at[108]); MULADD(at[59], at[107]); MULADD(at[60], at[106]); MULADD(at[61], at[105]); MULADD(at[62], at[104]); MULADD(at[63], at[103]);
|
||||
COMBA_STORE(C->dp[102]);
|
||||
|
||||
/* early out at 104 digits, 104*32==3328, or two 1664 bit operands */
|
||||
if (out_size <= 104) { COMBA_STORE2(C->dp[103]); C->used = 104; C->sign = A->sign ^ B->sign; fp_clamp(C); COMBA_FINI; return; }
|
||||
|
||||
/* 103 */
|
||||
COMBA_FORWARD;
|
||||
MULADD(at[40], at[127]); MULADD(at[41], at[126]); MULADD(at[42], at[125]); MULADD(at[43], at[124]); MULADD(at[44], at[123]); MULADD(at[45], at[122]); MULADD(at[46], at[121]); MULADD(at[47], at[120]); MULADD(at[48], at[119]); MULADD(at[49], at[118]); MULADD(at[50], at[117]); MULADD(at[51], at[116]); MULADD(at[52], at[115]); MULADD(at[53], at[114]); MULADD(at[54], at[113]); MULADD(at[55], at[112]); MULADD(at[56], at[111]); MULADD(at[57], at[110]); MULADD(at[58], at[109]); MULADD(at[59], at[108]); MULADD(at[60], at[107]); MULADD(at[61], at[106]); MULADD(at[62], at[105]); MULADD(at[63], at[104]);
|
||||
@ -496,10 +454,6 @@ void fp_mul_comba64(fp_int *A, fp_int *B, fp_int *C)
|
||||
COMBA_FORWARD;
|
||||
MULADD(at[47], at[127]); MULADD(at[48], at[126]); MULADD(at[49], at[125]); MULADD(at[50], at[124]); MULADD(at[51], at[123]); MULADD(at[52], at[122]); MULADD(at[53], at[121]); MULADD(at[54], at[120]); MULADD(at[55], at[119]); MULADD(at[56], at[118]); MULADD(at[57], at[117]); MULADD(at[58], at[116]); MULADD(at[59], at[115]); MULADD(at[60], at[114]); MULADD(at[61], at[113]); MULADD(at[62], at[112]); MULADD(at[63], at[111]);
|
||||
COMBA_STORE(C->dp[110]);
|
||||
|
||||
/* early out at 112 digits, 112*32==3584, or two 1792 bit operands */
|
||||
if (out_size <= 112) { COMBA_STORE2(C->dp[111]); C->used = 112; C->sign = A->sign ^ B->sign; fp_clamp(C); COMBA_FINI; return; }
|
||||
|
||||
/* 111 */
|
||||
COMBA_FORWARD;
|
||||
MULADD(at[48], at[127]); MULADD(at[49], at[126]); MULADD(at[50], at[125]); MULADD(at[51], at[124]); MULADD(at[52], at[123]); MULADD(at[53], at[122]); MULADD(at[54], at[121]); MULADD(at[55], at[120]); MULADD(at[56], at[119]); MULADD(at[57], at[118]); MULADD(at[58], at[117]); MULADD(at[59], at[116]); MULADD(at[60], at[115]); MULADD(at[61], at[114]); MULADD(at[62], at[113]); MULADD(at[63], at[112]);
|
||||
@ -532,10 +486,6 @@ void fp_mul_comba64(fp_int *A, fp_int *B, fp_int *C)
|
||||
COMBA_FORWARD;
|
||||
MULADD(at[55], at[127]); MULADD(at[56], at[126]); MULADD(at[57], at[125]); MULADD(at[58], at[124]); MULADD(at[59], at[123]); MULADD(at[60], at[122]); MULADD(at[61], at[121]); MULADD(at[62], at[120]); MULADD(at[63], at[119]);
|
||||
COMBA_STORE(C->dp[118]);
|
||||
|
||||
/* early out at 120 digits, 120*32==3840, or two 1920 bit operands */
|
||||
if (out_size <= 120) { COMBA_STORE2(C->dp[119]); C->used = 120; C->sign = A->sign ^ B->sign; fp_clamp(C); COMBA_FINI; return; }
|
||||
|
||||
/* 119 */
|
||||
COMBA_FORWARD;
|
||||
MULADD(at[56], at[127]); MULADD(at[57], at[126]); MULADD(at[58], at[125]); MULADD(at[59], at[124]); MULADD(at[60], at[123]); MULADD(at[61], at[122]); MULADD(at[62], at[121]); MULADD(at[63], at[120]);
|
||||
@ -575,3 +525,8 @@ void fp_mul_comba64(fp_int *A, fp_int *B, fp_int *C)
|
||||
COMBA_FINI;
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
/* $Source$ */
|
||||
/* $Revision$ */
|
||||
/* $Date$ */
|
||||
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue
Block a user