ext-cryptopp/rdrand-nasm.sh
Jeffrey Walton f9773d2961
Updated RDRAND and RDSEED under NASM
Port rdrand.S to Solaris
Port rdrand.S to X32
The X32 port is responsible for the loop unwinding. The unwind generates a 32-byte block (X64 and X32) or 16-byte block (X86). On X32, it increases throughut by 100% (doubles it). On X86 and X64, throughput increases by about 6%. Anything over 4 machine words slows things down.
2017-03-14 06:07:37 -04:00

43 lines
1.3 KiB
Bash
Executable File

#!/usr/bin/env bash
IS_LINUX=$(uname -s | grep -i -c linux)
IS_SOLARIS=$(uname -s | grep -i -c sunos)
IS_DARWIN=$(uname -s | grep -i -c darwin)
IS_CYGWIN=$(uname -s | grep -i -c cygwin)
rm -f rdrand-x86.o rdrand-x32.o rdrand-x64.o &>/dev/null
NASM=$(which nasm 2>&1)
if [[ ! -f "$NASM" ]]; then
echo "Unable to locate Nasm"
[ "$0" = "$BASH_SOURCE" ] && exit 1 || return 1
fi
if [[ "$IS_LINUX" -eq "1" ]]; then
echo "Building rdrand and rdseed modules for Linux"
nasm -f elf32 rdrand.S -DX86 -g -o rdrand-x86.o
nasm -f elfx32 rdrand.S -DX32 -g -o rdrand-x32.o
nasm -f elf64 rdrand.S -DX64 -g -o rdrand-x64.o
fi
if [[ "$IS_SOLARIS" -eq "1" ]]; then
echo "Building rdrand and rdseed modules for Solaris"
nasm -f elf32 rdrand.S -DX86 -o rdrand-x86.o
nasm -f elfx32 rdrand.S -DX32 -o rdrand-x32.o
nasm -f elf64 rdrand.S -DX64 -o rdrand-x64.o
fi
if [[ "$IS_DARWIN" -eq "1" ]]; then
echo "Building rdrand and rdseed modules for Darwin"
nasm -f macho32 rdrand.S -DDARWIN -DX86 -g -o rdrand-x86.o
nasm -f macho64 rdrand.S -DDARWIN -DX64 -g -o rdrand-x64.o
fi
if [[ "$IS_CYGWIN" -eq "1" ]]; then
echo "Building rdrand and rdseed modules for Cygwin"
nasm -f win32 rdrand.S -DCYGWIN -DX86 -g -o rdrand-x86.o
nasm -f win64 rdrand.S -DCYGWIN -DX64 -g -o rdrand-x64.o
fi
[ "$0" = "$BASH_SOURCE" ] && exit 0 || return 0