+++ /dev/null
-From 06669d85088f588ceb781f93367bb5428874ed27 Mon Sep 17 00:00:00 2001
-From: Andreas Cadhalpun <Andreas.Cadhalpun@googlemail.com>
-Date: Wed, 11 Mar 2015 20:03:15 +0100
-Subject: add support for system tomsfastmath
-
-Patch-Name: add-support-for-system-tomsfastmath.patch
----
- configure.ac | 2 ++
- libclamav/Makefile.am | 10 ++++++++--
- libclamav/bignum.h | 6 +++++-
- libclamav/xdp.c | 2 +-
- m4/reorganization/libs/tomsfastmath.m4 | 12 ++++++++++++
- 5 files changed, 28 insertions(+), 4 deletions(-)
- create mode 100644 m4/reorganization/libs/tomsfastmath.m4
-
-diff -urNp -x '*.orig' clamav-0.103.0.org/libclamav/bignum.h clamav-0.103.0/libclamav/bignum.h
---- clamav-0.103.0.org/libclamav/bignum.h 2020-09-13 02:27:09.000000000 +0200
-+++ clamav-0.103.0/libclamav/bignum.h 2021-04-06 16:40:12.578841141 +0200
-@@ -1,9 +1,13 @@
- #ifndef BIGNUM_H_
- #define BIGNUM_H_
-
-+#if HAVE_SYSTEM_TOMSFASTMATH
-+#include <tfm.h>
-+#else
- #define TFM_CHECK
--
- #include "bignum_fast.h"
-+#endif
-+
- typedef fp_int mp_int;
- #define mp_cmp fp_cmp
- #define mp_toradix_n(a, b, c, d) fp_toradix_n(a, b, c, d)
-diff -urNp -x '*.orig' clamav-0.103.0.org/libclamav/xdp.c clamav-0.103.0/libclamav/xdp.c
---- clamav-0.103.0.org/libclamav/xdp.c 2020-09-13 02:27:10.000000000 +0200
-+++ clamav-0.103.0/libclamav/xdp.c 2021-04-06 16:40:12.578841141 +0200
-@@ -52,7 +52,7 @@
- #include "scanners.h"
- #include "conv.h"
- #include "xdp.h"
--#include "bignum_fast.h"
-+#include "bignum.h"
- #include "filetypes.h"
-
- static char *dump_xdp(cli_ctx *ctx, const char *start, size_t sz);
-
---- clamav-0.104.0/libclamav/CMakeLists.txt~ 2021-08-27 22:41:31.000000000 +0000
-+++ clamav-0.104.0/libclamav/CMakeLists.txt 2021-10-08 14:11:34.629965363 +0000
-@@ -157,99 +157,6 @@ target_link_libraries( yara
- PCRE2::pcre2
- JSONC::jsonc )
-
--add_library( tomsfastmath OBJECT )
--target_sources( tomsfastmath
-- PRIVATE
-- tomsfastmath/addsub/fp_add.c
-- tomsfastmath/addsub/fp_add_d.c
-- tomsfastmath/addsub/fp_addmod.c
-- tomsfastmath/addsub/fp_cmp.c
-- tomsfastmath/addsub/fp_cmp_d.c
-- tomsfastmath/addsub/fp_cmp_mag.c
-- tomsfastmath/addsub/fp_sub.c
-- tomsfastmath/addsub/fp_sub_d.c
-- tomsfastmath/addsub/fp_submod.c
-- tomsfastmath/addsub/s_fp_add.c
-- tomsfastmath/addsub/s_fp_sub.c
-- tomsfastmath/bin/fp_radix_size.c
-- tomsfastmath/bin/fp_read_radix.c
-- tomsfastmath/bin/fp_read_signed_bin.c
-- tomsfastmath/bin/fp_read_unsigned_bin.c
-- tomsfastmath/bin/fp_reverse.c
-- tomsfastmath/bin/fp_s_rmap.c
-- tomsfastmath/bin/fp_signed_bin_size.c
-- tomsfastmath/bin/fp_to_signed_bin.c
-- tomsfastmath/bin/fp_to_unsigned_bin.c
-- tomsfastmath/bin/fp_toradix.c
-- tomsfastmath/bin/fp_toradix_n.c
-- tomsfastmath/bin/fp_unsigned_bin_size.c
-- tomsfastmath/bit/fp_cnt_lsb.c
-- tomsfastmath/bit/fp_count_bits.c
-- tomsfastmath/bit/fp_div_2.c
-- tomsfastmath/bit/fp_div_2d.c
-- tomsfastmath/bit/fp_lshd.c
-- tomsfastmath/bit/fp_mod_2d.c
-- tomsfastmath/bit/fp_rshd.c
-- tomsfastmath/divide/fp_div.c
-- tomsfastmath/divide/fp_div_d.c
-- tomsfastmath/divide/fp_mod.c
-- tomsfastmath/divide/fp_mod_d.c
-- tomsfastmath/exptmod/fp_2expt.c
-- tomsfastmath/exptmod/fp_exptmod.c
-- tomsfastmath/misc/fp_ident.c
-- tomsfastmath/misc/fp_set.c
-- tomsfastmath/mont/fp_montgomery_calc_normalization.c
-- tomsfastmath/mont/fp_montgomery_reduce.c
-- tomsfastmath/mont/fp_montgomery_setup.c
-- tomsfastmath/mul/fp_mul.c
-- tomsfastmath/mul/fp_mul_comba.c
-- tomsfastmath/mul/fp_mul_2.c
-- tomsfastmath/mul/fp_mul_2d.c
-- tomsfastmath/mul/fp_mul_comba_12.c
-- tomsfastmath/mul/fp_mul_comba_17.c
-- tomsfastmath/mul/fp_mul_comba_20.c
-- tomsfastmath/mul/fp_mul_comba_24.c
-- tomsfastmath/mul/fp_mul_comba_28.c
-- tomsfastmath/mul/fp_mul_comba_3.c
-- tomsfastmath/mul/fp_mul_comba_32.c
-- tomsfastmath/mul/fp_mul_comba_4.c
-- tomsfastmath/mul/fp_mul_comba_48.c
-- tomsfastmath/mul/fp_mul_comba_6.c
-- tomsfastmath/mul/fp_mul_comba_64.c
-- tomsfastmath/mul/fp_mul_comba_7.c
-- tomsfastmath/mul/fp_mul_comba_8.c
-- tomsfastmath/mul/fp_mul_comba_9.c
-- tomsfastmath/mul/fp_mul_comba_small_set.c
-- tomsfastmath/mul/fp_mul_d.c
-- tomsfastmath/mul/fp_mulmod.c
-- tomsfastmath/numtheory/fp_invmod.c
-- tomsfastmath/sqr/fp_sqr.c
-- tomsfastmath/sqr/fp_sqr_comba_12.c
-- tomsfastmath/sqr/fp_sqr_comba_17.c
-- tomsfastmath/sqr/fp_sqr_comba_20.c
-- tomsfastmath/sqr/fp_sqr_comba_24.c
-- tomsfastmath/sqr/fp_sqr_comba_28.c
-- tomsfastmath/sqr/fp_sqr_comba_3.c
-- tomsfastmath/sqr/fp_sqr_comba_32.c
-- tomsfastmath/sqr/fp_sqr_comba_4.c
-- tomsfastmath/sqr/fp_sqr_comba_48.c
-- tomsfastmath/sqr/fp_sqr_comba_6.c
-- tomsfastmath/sqr/fp_sqr_comba_64.c
-- tomsfastmath/sqr/fp_sqr_comba_7.c
-- tomsfastmath/sqr/fp_sqr_comba_8.c
-- tomsfastmath/sqr/fp_sqr_comba_9.c
-- tomsfastmath/sqr/fp_sqr_comba_generic.c
-- tomsfastmath/sqr/fp_sqr_comba_small_set.c
-- tomsfastmath/sqr/fp_sqrmod.c
-- PUBLIC
-- bignum.h
-- bignum_fast.h )
--target_include_directories( tomsfastmath
-- PRIVATE ${CMAKE_BINARY_DIR}
-- PUBLIC ${CMAKE_CURRENT_SOURCE_DIR} )
--set_target_properties( tomsfastmath PROPERTIES
-- COMPILE_FLAGS "${WARNCFLAGS}" )
--
- # Bytecode Runtime
- add_library( bytecode_runtime OBJECT )
- if(LLVM_FOUND)
-@@ -424,7 +424,7 @@ if(ENABLE_SHARED_LIB)
- regex
- lzma_sdk
- yara
-- tomsfastmath
-+ tfm
- bytecode_runtime
- ${LIBMSPACK}
- ClamAV::libunrar_iface_iface
-@@ -525,7 +525,7 @@ if(ENABLE_STATIC_LIB)
- regex
- lzma_sdk
- yara
-- tomsfastmath
-+ tfm
- bytecode_runtime
- ${LIBMSPACK}
- OpenSSL::SSL
---- clamav-0.104.0/unit_tests/CMakeLists.txt~ 2021-08-27 22:41:31.000000000 +0000
-+++ clamav-0.104.0/unit_tests/CMakeLists.txt 2021-10-08 14:20:36.239965193 +0000
-@@ -52,7 +52,7 @@ if(ENABLE_APP)
- regex
- lzma_sdk
- yara
-- tomsfastmath
-+ tfm
- bytecode_runtime
- JSONC::jsonc
- ${LIBMSPACK}
-@@ -92,7 +92,7 @@ if(ENABLE_APP)
- regex
- lzma_sdk
- yara
-- tomsfastmath
-+ tfm
- bytecode_runtime
- JSONC::jsonc
- ${LIBMSPACK}
-@@ -144,7 +144,7 @@ target_link_libraries(check_clamav
- regex
- lzma_sdk
- yara
-- tomsfastmath
-+ tfm
- bytecode_runtime
- JSONC::jsonc
- ${LIBMSPACK}
tv1.tv_sec * 1000000 + tv1.tv_usec, pc);
}
if (stop == CL_EBYTECODE) {
---- clamav-0.104.1/libclamav/bignum_fast.h.orig 2021-11-02 20:09:25.000000000 +0100
-+++ clamav-0.104.1/libclamav/bignum_fast.h 2021-12-11 10:43:55.832213985 +0100
-@@ -102,7 +102,7 @@
+--- clamav-0.104.1/libclamav/tomsfastmath/headers/tfm.h.orig 2021-11-02 20:09:25.000000000 +0100
++++ clamav-0.104.1/libclamav/tomsfastmath/headers/tfm.h 2021-12-11 10:43:55.832213985 +0100
+@@ -118,7 +118,7 @@
#endif
/* autodetect x86-64 and make sure we are using 64-bit digits with x86-64 asm */
-#if defined(__x86_64__)
+#if defined(__x86_64__) && !defined(__ILP32__)
- #if defined(TFM_X86) || defined(TFM_SSE2) || defined(TFM_ARM)
- #error x86-64 detected, x86-32/SSE2/ARM optimizations are not valid!
- #endif
-@@ -117,7 +117,7 @@
+ #if defined(TFM_X86) || defined(TFM_SSE2) || defined(TFM_ARM)
+ #error x86-64 detected, x86-32/SSE2/ARM optimizations are not valid!
+ #endif
+@@ -133,7 +133,7 @@
#endif
/* try to detect x86-32 */
-#if defined(__i386__) && !defined(TFM_SSE2)
+#if (defined(__i386__) || defined(__ILP32__)) && !defined(TFM_SSE2)
- #if defined(TFM_X86_64) || defined(TFM_ARM)
- #error x86-32 detected, x86-64/ARM optimizations are not valid!
- #endif
+ #if defined(TFM_X86_64) || defined(TFM_ARM)
+ #error x86-32 detected, x86-64/ARM optimizations are not valid!
+ #endif
--- clamav-0.104.1/libclamav/tomsfastmath/mont/fp_montgomery_reduce.c.orig 2021-12-11 10:41:02.011008906 +0100
+++ clamav-0.104.1/libclamav/tomsfastmath/mont/fp_montgomery_reduce.c 2021-12-11 10:41:23.713556450 +0100
-@@ -42,7 +42,7 @@
+@@ -42,7 +42,7 @@ asm(
: "%eax", "cc")
/******************************************************************/
+#elif defined(TFM_X86_64) && !defined(__ILP32__)
/* x86-64 code */
- #define MONT_START
+ #define MONT_START
+