1 From 756ff89526b5ffaa7a4f49b1bbecf2ecbd6f85f9 Mon Sep 17 00:00:00 2001
2 From: Andreas Cadhalpun <Andreas.Cadhalpun@googlemail.com>
3 Date: Wed, 11 Mar 2015 20:03:15 +0100
4 Subject: add support for system tomsfastmath
6 Patch-Name: add-support-for-system-tomsfastmath.patch
9 libclamav/Makefile.am | 10 ++++++++--
10 libclamav/bignum.h | 6 +++++-
11 libclamav/xdp.c | 2 +-
12 m4/reorganization/libs/tomsfastmath.m4 | 12 ++++++++++++
13 5 files changed, 28 insertions(+), 4 deletions(-)
14 create mode 100644 m4/reorganization/libs/tomsfastmath.m4
18 @@ -82,6 +82,7 @@ m4_include([m4/reorganization/libs/xml.m
19 m4_include([m4/reorganization/libs/openssl.m4])
20 m4_include([m4/reorganization/libs/json.m4])
21 m4_include([m4/reorganization/libs/pcre.m4])
22 +m4_include([m4/reorganization/libs/tomsfastmath.m4])
25 m4_include([m4/reorganization/libs/libz.m4])
26 @@ -285,6 +286,7 @@ else
28 CL_MSG_STATUS([yara ],[$enable_yara],[$enable_yara])
29 CL_MSG_STATUS([fts ],[yes],[$lfs_fts_msg])
30 +CL_MSG_STATUS([tomsfastmath],[yes],[$tomsfastmath_msg])
33 # Yep, downgrading the compiler avoids the bug too:
34 --- a/libclamav/Makefile.am
35 +++ b/libclamav/Makefile.am
36 @@ -496,8 +496,10 @@ libclamav_la_SOURCES += yara_arena.c \
40 -libclamav_la_SOURCES += bignum.h\
42 +libclamav_la_SOURCES += bignum.h
44 +if !SYSTEM_TOMSFASTMATH
45 +libclamav_la_SOURCES += bignum_fast.h\
46 tomsfastmath/addsub/fp_add.c\
47 tomsfastmath/addsub/fp_add_d.c\
48 tomsfastmath/addsub/fp_addmod.c\
49 @@ -579,6 +581,10 @@ libclamav_la_SOURCES += bignum.h\
50 tomsfastmath/sqr/fp_sqr_comba_generic.c\
51 tomsfastmath/sqr/fp_sqr_comba_small_set.c\
52 tomsfastmath/sqr/fp_sqrmod.c
54 +libclamav_la_CFLAGS += $(TOMSFASTMATH_CFLAGS)
55 +libclamav_la_LIBADD += $(TOMSFASTMATH_LIBS)
60 --- a/libclamav/bignum.h
61 +++ b/libclamav/bignum.h
66 +#if HAVE_SYSTEM_TOMSFASTMATH
71 #include "bignum_fast.h"
74 typedef fp_int mp_int;
76 #define mp_toradix_n(a,b,c,d) fp_toradix_n(a,b,c,d)
83 -#include "bignum_fast.h"
85 #include "filetypes.h"
87 static char *dump_xdp(cli_ctx *ctx, const char *start, size_t sz);
89 +++ b/m4/reorganization/libs/tomsfastmath.m4
91 +dnl Check for system tomsfastmath
92 +PKG_CHECK_MODULES([TOMSFASTMATH], [tomsfastmath], [have_system_tomsfastmath=yes], [have_system_tomsfastmath=no])
94 +AM_CONDITIONAL([SYSTEM_TOMSFASTMATH], [test "x$have_system_tomsfastmath" = "xyes"])
96 +if test "x$have_system_tomsfastmath" = "xyes"; then
97 + AC_DEFINE([HAVE_SYSTEM_TOMSFASTMATH], [1], [link against system-wide tomsfastmath library])
98 + tomsfastmath_msg="External, $TOMSFASTMATH_CFLAGS $TOMSFASTMATH_LIBS"
100 + AC_DEFINE([HAVE_SYSTEM_TOMSFASTMATH], [0], [don't link against system-wide tomsfastmath library])
101 + tomsfastmath_msg="Internal"