gnu: Add kafs-client
[jackhill/guix/guix.git] / gnu / packages / patches / clamav-system-tomsfastmath.patch
1 From: Tobias Geerinckx-Rice <me@tobias.gr>
2 Date: Sat, 03 Oct 2020 22:10:20 +0200
3 Subject: gnu: clamav: Add support for system tomsfastmath.
4
5 Adjusted from the original for clamav 0.103.0:
6
7 From 756ff89526b5ffaa7a4f49b1bbecf2ecbd6f85f9 Mon Sep 17 00:00:00 2001
8 From: Andreas Cadhalpun <Andreas.Cadhalpun@googlemail.com>
9 Date: Wed, 11 Mar 2015 20:03:15 +0100
10 Subject: add support for system tomsfastmath
11
12 Patch-Name: add-support-for-system-tomsfastmath.patch
13 ---
14 configure.ac | 2 ++
15 libclamav/Makefile.am | 10 ++++++++--
16 libclamav/bignum.h | 6 +++++-
17 libclamav/xdp.c | 2 +-
18 m4/reorganization/libs/tomsfastmath.m4 | 12 ++++++++++++
19 5 files changed, 28 insertions(+), 4 deletions(-)
20 create mode 100644 m4/reorganization/libs/tomsfastmath.m4
21
22 diff -Naur a/configure.ac b/configure.ac
23 --- a/configure.ac 1970-01-01 01:00:01.000000000 +0100
24 +++ b/configure.ac 2020-10-03 22:04:00.535448352 +0200
25 @@ -94,6 +94,7 @@
26 m4_include([m4/reorganization/libs/json.m4])
27 m4_include([m4/reorganization/libs/pcre.m4])
28 m4_include([m4/reorganization/libs/libmspack.m4])
29 +m4_include([m4/reorganization/libs/tomsfastmath.m4])
30
31 if test "x$use_internal_mspack" = "xno"; then
32 mspack_msg="External, $LIBMSPACK_CFLAGS $LIBMSPACK_LIBS"
33 @@ -361,6 +362,7 @@
34 fi
35 CL_MSG_STATUS([yara ],[$enable_yara],[$enable_yara])
36 CL_MSG_STATUS([fts ],[yes],[$lfs_fts_msg])
37 +CL_MSG_STATUS([tomsfastmath],[yes],[$tomsfastmath_msg])
38
39
40 # Yep, downgrading the compiler avoids the bug too:
41 diff -Naur a/libclamav/bignum.h b/libclamav/bignum.h
42 --- a/libclamav/bignum.h 1970-01-01 01:00:01.000000000 +0100
43 +++ b/libclamav/bignum.h 2020-10-03 22:04:00.535448352 +0200
44 @@ -1,9 +1,13 @@
45 #ifndef BIGNUM_H_
46 #define BIGNUM_H_
47
48 +#if HAVE_SYSTEM_TOMSFASTMATH
49 +#include <tfm.h>
50 +#else
51 #define TFM_CHECK
52 -
53 #include "bignum_fast.h"
54 +#endif
55 +
56 typedef fp_int mp_int;
57 #define mp_cmp fp_cmp
58 #define mp_toradix_n(a, b, c, d) fp_toradix_n(a, b, c, d)
59 diff -Naur a/libclamav/Makefile.am b/libclamav/Makefile.am
60 --- a/libclamav/Makefile.am 1970-01-01 01:00:01.000000000 +0100
61 +++ b/libclamav/Makefile.am 2020-10-03 22:06:42.705447754 +0200
62 @@ -588,8 +588,10 @@
63 yara_clam.h
64 endif
65
66 -libclamav_la_SOURCES += bignum.h\
67 - bignum_fast.h\
68 +libclamav_la_SOURCES += bignum.h
69 +
70 +if !SYSTEM_TOMSFASTMATH
71 +libclamav_la_SOURCES += bignum_fast.h\
72 tomsfastmath/addsub/fp_add.c\
73 tomsfastmath/addsub/fp_add_d.c\
74 tomsfastmath/addsub/fp_addmod.c\
75 @@ -671,6 +673,10 @@
76 tomsfastmath/sqr/fp_sqr_comba_generic.c\
77 tomsfastmath/sqr/fp_sqr_comba_small_set.c\
78 tomsfastmath/sqr/fp_sqrmod.c
79 +else
80 +libclamav_la_CFLAGS += $(TOMSFASTMATH_CFLAGS)
81 +libclamav_la_LIBADD += $(TOMSFASTMATH_LIBS)
82 +endif
83
84 .PHONY2: version.h.tmp
85 version.c: version.h
86 diff -Naur a/libclamav/xdp.c b/libclamav/xdp.c
87 --- a/libclamav/xdp.c 1970-01-01 01:00:01.000000000 +0100
88 +++ b/libclamav/xdp.c 2020-10-03 22:04:00.535448352 +0200
89 @@ -52,7 +52,7 @@
90 #include "scanners.h"
91 #include "conv.h"
92 #include "xdp.h"
93 -#include "bignum_fast.h"
94 +#include "bignum.h"
95 #include "filetypes.h"
96
97 static char *dump_xdp(cli_ctx *ctx, const char *start, size_t sz);
98 diff -Naur a/m4/reorganization/libs/tomsfastmath.m4 b/m4/reorganization/libs/tomsfastmath.m4
99 --- a/m4/reorganization/libs/tomsfastmath.m4 1970-01-01 01:00:00.000000000 +0100
100 +++ b/m4/reorganization/libs/tomsfastmath.m4 2020-10-03 22:04:00.535448352 +0200
101 @@ -0,0 +1,12 @@
102 +dnl Check for system tomsfastmath
103 +PKG_CHECK_MODULES([TOMSFASTMATH], [tomsfastmath], [have_system_tomsfastmath=yes], [have_system_tomsfastmath=no])
104 +
105 +AM_CONDITIONAL([SYSTEM_TOMSFASTMATH], [test "x$have_system_tomsfastmath" = "xyes"])
106 +
107 +if test "x$have_system_tomsfastmath" = "xyes"; then
108 + AC_DEFINE([HAVE_SYSTEM_TOMSFASTMATH], [1], [link against system-wide tomsfastmath library])
109 + tomsfastmath_msg="External, $TOMSFASTMATH_CFLAGS $TOMSFASTMATH_LIBS"
110 +else
111 + AC_DEFINE([HAVE_SYSTEM_TOMSFASTMATH], [0], [don't link against system-wide tomsfastmath library])
112 + tomsfastmath_msg="Internal"
113 +fi