summaryrefslogtreecommitdiffstats
path: root/secure/lib
diff options
context:
space:
mode:
authorkris <kris@FreeBSD.org>2001-02-19 03:59:05 +0000
committerkris <kris@FreeBSD.org>2001-02-19 03:59:05 +0000
commit337d7ba539a9d8f5f19110edd365ae6d3a7d8aba (patch)
tree60450ca990b063182ef023cd353e304633e4be4f /secure/lib
parent405108c6cdec7aa38d58c740b468341671eca930 (diff)
downloadFreeBSD-src-337d7ba539a9d8f5f19110edd365ae6d3a7d8aba.zip
FreeBSD-src-337d7ba539a9d8f5f19110edd365ae6d3a7d8aba.tar.gz
Introduce support for using OpenSSL ASM optimizations. This is done
through the use of a new build directive, MACHINE_CPU, which contains a list of the CPU generations/features for which optimizations are desired. This feature will be extended to cover the ports tree in the future. Currently OpenSSL provides optimizations for i386, i586 and i686-class CPUs. Currently it has not been tested on an i386 or i486. Teach make(1) to provide sensible defaults for MACHINE_CPU if it is not defined (namely, the lowest common denominator CPU we support for each architecture). Currently this is i386 for the i386 architecture and ev4 for the alpha. sys.mk also sets the variable as a last resort for consistency with MACHINE_ARCH and bootstrapping from very old versions of make. Benchmarks show a significant speed increase even in the i386 case, with additional improvements for i586 and i686 systems. For maximum performance define MACHINE_CPU=i686 i586 i386 in /etc/make.conf. Based on a patch submitted by: Mike Silbersack <silby@silby.com> Reviewed by: current
Diffstat (limited to 'secure/lib')
-rw-r--r--secure/lib/libcrypto/Makefile92
-rw-r--r--secure/lib/libcrypto/Makefile.inc9
2 files changed, 91 insertions, 10 deletions
diff --git a/secure/lib/libcrypto/Makefile b/secure/lib/libcrypto/Makefile
index 7fb60be..2810957 100644
--- a/secure/lib/libcrypto/Makefile
+++ b/secure/lib/libcrypto/Makefile
@@ -16,6 +16,15 @@
${LCRYPTO_SRC}/stack ${LCRYPTO_SRC}/txt_db ${LCRYPTO_SRC}/x509 \
${LCRYPTO_SRC}/x509v3
+.if !defined(NOPERL) && ${MACHINE_ARCH} == "i386"
+.PATH: ${LCRYPTO_SRC}/rc4/asm ${LCRYPTO_SRC}/rc5/asm \
+ ${LCRYPTO_SRC}/des/asm ${LCRYPTO_SRC}/cast/asm \
+ ${LCRYPTO_SRC}/sha/asm ${LCRYPTO_SRC}/bn/asm \
+ ${LCRYPTO_SRC}/bf/asm ${LCRYPTO_SRC}/md5/asm \
+ ${LCRYPTO_SRC}/ripemd/asm
+PERLPATH= ${LCRYPTO_SRC}/des/asm:${LCRYPTO_SRC}/perlasm
+.endif
+
.if defined(MAKE_IDEA) && ${MAKE_IDEA} == YES
.PATH: ${LCRYPTO_SRC}/idea
.endif
@@ -48,7 +57,16 @@ SRCS+= a_bitstr.c a_bmp.c a_bool.c a_bytes.c a_d2i_fp.c a_digest.c \
x_req.c x_sig.c x_spki.c x_val.c x_x509.c x_x509a.c
# blowfish
-SRCS+= bf_cfb64.c bf_ecb.c bf_enc.c bf_ofb64.c bf_skey.c
+SRCS+= bf_cfb64.c bf_ecb.c bf_ofb64.c bf_skey.c
+.if !defined(NOPERL) && ${MACHINE_ARCH} == "i386"
+.if ${MACHINE_CPU:Mi686}
+SRCS+= bf-686.pl
+.else
+SRCS+= bf-586.pl
+.endif
+.else
+SRCS+= bf_enc.c
+.endif
# bio
SRCS+= b_dump.c b_print.c b_sock.c bf_buff.c bf_nbio.c bf_null.c \
@@ -57,16 +75,28 @@ SRCS+= b_dump.c b_print.c b_sock.c bf_buff.c bf_nbio.c bf_null.c \
# bn
-SRCS+= bn_add.c bn_asm.c bn_blind.c bn_ctx.c bn_div.c bn_err.c \
+SRCS+= bn_add.c bn_blind.c bn_ctx.c bn_div.c bn_err.c \
bn_exp.c bn_exp2.c bn_gcd.c bn_lib.c bn_mont.c bn_mpi.c \
bn_mul.c bn_prime.c bn_print.c bn_rand.c bn_recp.c bn_shift.c \
bn_sqr.c bn_word.c
+.if !defined(NOPERL) && ${MACHINE_ARCH} == "i386"
+SRCS+= bn-586.pl co-586.pl
+.elif ${MACHINE_ARCH} == "alpha"
+SRCS+= bn-alpha.pl co-alpha.pl
+.else
+SRCS+= bn_asm.c
+.endif
# buffer
SRCS+= buf_err.c buffer.c
# cast
-SRCS+= c_cfb64.c c_ecb.c c_enc.c c_ofb64.c c_skey.c
+SRCS+= c_cfb64.c c_ecb.c c_ofb64.c c_skey.c
+.if !defined(NOPERL) && ${MACHINE_ARCH} == "i386"
+SRCS+= cast-586.pl
+.else
+SRCS+= c_enc.c
+.endif
# comp
SRCS+= c_rle.c c_zlib.c comp_lib.c
@@ -75,11 +105,16 @@ SRCS+= c_rle.c c_zlib.c comp_lib.c
SRCS+= conf_api.c conf_def.c conf_err.c conf_lib.c
# des
-SRCS+= cbc_cksm.c cbc_enc.c cfb64ede.c cfb64enc.c cfb_enc.c des_enc.c \
+SRCS+= cbc_cksm.c cbc_enc.c cfb64ede.c cfb64enc.c cfb_enc.c \
ecb3_enc.c ecb_enc.c ede_cbcm_enc.c enc_read.c enc_writ.c \
- fcrypt.c fcrypt_b.c ofb64ede.c ofb64enc.c ofb_enc.c pcbc_enc.c \
+ fcrypt.c ofb64ede.c ofb64enc.c ofb_enc.c pcbc_enc.c \
qud_cksm.c rand_key.c read2pwd.c read_pwd.c rpc_enc.c \
set_key.c str2key.c xcbc_enc.c rnd_keys.c
+.if !defined(NOPERL) && ${MACHINE_ARCH} == "i386"
+SRCS+= des-586.pl crypt586.pl
+.else
+SRCS+= des_enc.c
+.endif
# dh
SRCS+= dh_check.c dh_err.c dh_gen.c dh_key.c dh_lib.c
@@ -123,6 +158,9 @@ SRCS+= md4_dgst.c md4_one.c
# md5
SRCS+= md5_dgst.c md5_one.c
+.if !defined(NOPERL) && ${MACHINE_ARCH} == "i386"
+SRCS+= md5-586.pl
+.endif
# mdc2
SRCS+= mdc2dgst.c mdc2_one.c
@@ -148,13 +186,26 @@ SRCS+= md_rand.c rand_egd.c rand_err.c rand_lib.c rand_win.c randfile.c
SRCS+= rc2_cbc.c rc2cfb64.c rc2_ecb.c rc2ofb64.c rc2_skey.c
# rc4
-SRCS+= rc4_enc.c rc4_skey.c
+SRCS+= rc4_skey.c
+.if !defined(NOPERL) && ${MACHINE_ARCH} == "i386"
+SRCS+= rc4-586.pl
+.else
+SRCS+= rc4_enc.c
+.endif
# rc5
-SRCS+= rc5cfb64.c rc5_ecb.c rc5_enc.c rc5ofb64.c rc5_skey.c
+SRCS+= rc5cfb64.c rc5_ecb.c rc5ofb64.c rc5_skey.c
+.if !defined(NOPERL) && ${MACHINE_ARCH} == "i386"
+SRCS+= rc5-586.pl
+.else
+SRCS+= rc5_enc.c
+.endif
# ripemd
SRCS+= rmd_dgst.c rmd_one.c
+.if !defined(NOPERL) && ${MACHINE_ARCH} == "i386"
+SRCS+= rmd-586.pl
+.endif
# rsa
.if defined(WITH_RSA) && ${WITH_RSA} == YES
@@ -164,6 +215,9 @@ SRCS+= rsa_chk.c rsa_eay.c rsa_err.c rsa_gen.c rsa_lib.c rsa_none.c \
# sha
SRCS+= sha_dgst.c sha_one.c sha1_one.c sha1dgst.c
+.if !defined(NOPERL) && ${MACHINE_ARCH} == "i386"
+SRCS+= sha1-586.pl
+.endif
# stack
SRCS+= stack.c
@@ -263,6 +317,30 @@ beforeinstall: openssl/opensslconf.h openssl/evp.h
.include <bsd.lib.mk>
+# If we don't want 686/586 asm, use the "386" modifier to the perl scripts to give
+# compatible output
+.if !defined(NOPERL) && ${MACHINE_ARCH} == "i386"
+.if ${MACHINE_CPU:Mi686} || ${MACHINE_CPU:Mi586}
+CPUTYPE=
+.elif ${MACHINE_CPU:Mi386}
+CPUTYPE= 386
+.endif
+.endif
+
+.if !defined(NOPERL) && ${MACHINE_ARCH} == "i386"
+.SUFFIXES: .o .pl
+.SUFFIXES: .po .pl
+.SUFFIXES: .So .pl
+.pl.o:
+ perl -I${PERLPATH} $(.ALLSRC) elf ${CPUTYPE} > $(.PREFIX).pl.s ; ${AS} ${AFLAGS} $(.PREFIX).pl.s -o $(.TARGET)
+
+.pl.po:
+ perl -I${PERLPATH} $(.ALLSRC) elf ${CPUTYPE} > $(.PREFIX).pl.s ; ${AS} ${AFLAGS} $(.PREFIX).pl.s -o $(.TARGET)
+
+.pl.So:
+ perl -I${PERLPATH} $(.ALLSRC) elf ${CPUTYPE} > $(.PREFIX).pl.s ; ${AS} ${AFLAGS} $(.PREFIX).pl.s -o $(.TARGET)
+.endif
+
afterinstall:
.if !defined(NOPIC)
@cd ${DESTDIR}${SHLIBDIR}; \
diff --git a/secure/lib/libcrypto/Makefile.inc b/secure/lib/libcrypto/Makefile.inc
index 075d246..5f927eef 100644
--- a/secure/lib/libcrypto/Makefile.inc
+++ b/secure/lib/libcrypto/Makefile.inc
@@ -7,8 +7,10 @@ CFLAGS+= -DNO_IDEA
.endif
.if ${MACHINE_ARCH} == "i386"
-CFLAGS+= -DL_ENDIAN
-# -DBN_ASM -DSHA1_ASM -DMD5_ASM -DRMD160_ASM - XXX notyet
+CFLAGS+= -DL_ENDIAN
+.if !defined(NOPERL)
+CFLAGS+= -DSHA1_ASM -DBN_ASM -DMD5_ASM -DRMD160_ASM
+.endif
.elif ${MACHINE_ARCH} == "alpha"
# no ENDIAN stuff defined for alpha (64-bit)
.endif
@@ -23,7 +25,8 @@ HDRS= asn1/asn1.h asn1/asn1_mac.h bio/bio.h bf/blowfish.h bn/bn.h \
pem/pem2.h pkcs12/pkcs12.h pkcs7/pkcs7.h rand/rand.h rc2/rc2.h \
rc4/rc4.h rc5/rc5.h ripemd/ripemd.h rsa/rsa.h stack/safestack.h \
sha/sha.h stack/stack.h tmdiff.h txt_db/txt_db.h x509/x509.h \
- x509/x509_vfy.h x509v3/x509v3.h symhacks.h objects/obj_mac.h md4/md4.h dso/dso.h conf/conf_api.h
+ x509/x509_vfy.h x509v3/x509v3.h symhacks.h objects/obj_mac.h \
+ md4/md4.h dso/dso.h conf/conf_api.h
.if defined(MAKE_IDEA) && ${MAKE_IDEA} == YES
HDRS+= idea/idea.h
OpenPOWER on IntegriCloud