aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEric Bavier <bavier@member.fsf.org>2016-10-20 23:26:49 -0500
committerEric Bavier <bavier@member.fsf.org>2018-11-17 00:20:44 -0600
commit7ed018e8a2f885246461ad65420bf39d741d343c (patch)
tree19f16f673e89b2ce2ee3679a61aee0d00733ab4b
parentfc9dbf41311d99d0fd8befc789ea7c0e35911890 (diff)
downloadgnu-guix-7ed018e8a2f885246461ad65420bf39d741d343c.tar
gnu-guix-7ed018e8a2f885246461ad65420bf39d741d343c.tar.gz
gnu: Add TomsFastMath.
* gnu/packages/multiprecision.scm (tomsfastmath): New variable. * gnu/packages/patches/tomsfastmath-constness.patch: New patch. * gnu/local.mk (dist_patch_DATA): Add it.
-rw-r--r--gnu/local.mk1
-rw-r--r--gnu/packages/multiprecision.scm66
-rw-r--r--gnu/packages/patches/tomsfastmath-constness.patch76
3 files changed, 143 insertions, 0 deletions
diff --git a/gnu/local.mk b/gnu/local.mk
index 2a90a85a6c..e3aa0cd4cd 100644
--- a/gnu/local.mk
+++ b/gnu/local.mk
@@ -1178,6 +1178,7 @@ dist_patch_DATA = \
%D%/packages/patches/tk-find-library.patch \
%D%/packages/patches/ttf2eot-cstddef.patch \
%D%/packages/patches/ttfautohint-source-date-epoch.patch \
+ %D%/packages/patches/tomsfastmath-constness.patch \
%D%/packages/patches/totem-meson-easy-codec.patch \
%D%/packages/patches/tuxpaint-stamps-path.patch \
%D%/packages/patches/twinkle-include-qregexpvalidator.patch \
diff --git a/gnu/packages/multiprecision.scm b/gnu/packages/multiprecision.scm
index 4f5eac16b9..71e1efcd8c 100644
--- a/gnu/packages/multiprecision.scm
+++ b/gnu/packages/multiprecision.scm
@@ -26,6 +26,7 @@
(define-module (gnu packages multiprecision)
#:use-module (guix licenses)
#:use-module (gnu packages)
+ #:use-module (gnu packages autotools)
#:use-module (gnu packages m4)
#:use-module (gnu packages gcc)
#:use-module (guix packages)
@@ -225,3 +226,68 @@ minor changes to the source code. In most cases only a few type statements
and (for Fortran-90 programs) read/write statements need to be changed. PSLQ
and numerical quadrature programs are included.")
(license bsd-3)))
+
+(define-public tomsfastmath
+ (package
+ (name "tomsfastmath")
+ (version "0.13.0")
+ (synopsis "Large integer arithmetic library")
+ (source (origin
+ (method url-fetch)
+ (uri (string-append "https://github.com/libtom/tomsfastmath/"
+ "releases/download/v" version "/"
+ "tfm-" (version-major+minor version) ".tar.bz2"))
+ (sha256
+ (base32
+ "01rlsvp6lskk2a0gfdi24ak5h8vdwi6kqbvbwjnmb92r0zrfdvwd"))
+ (patches (search-patches "tomsfastmath-constness.patch"))))
+ (build-system gnu-build-system)
+ (native-inputs
+ `(("libtool" ,libtool)))
+ (arguments
+ `(#:make-flags (list "-f" "makefile.shared"
+ (string-append "LIBPATH=" %output "/lib")
+ (string-append "INCPATH=" %output "/include")
+ "GROUP=root" "USER=root"
+ "CC=gcc")
+ #:phases
+ (modify-phases %standard-phases
+ (delete 'configure) ;no configuration
+ (replace 'check
+ (lambda* (#:key make-flags #:allow-other-keys)
+ (and (zero? (apply system* "make"
+ "stest" "test_standalone"
+ make-flags))
+ (zero? (system* "./stest"))
+ (zero? (system* "./test")))))
+ (add-before 'install 'install-nogroup
+ (lambda _
+ ;; Let permissions inherit from the current process
+ (substitute* "makefile.shared"
+ (("-g \\$\\(GROUP\\) -o \\$\\(USER\\)") ""))
+ #t))
+ (add-after 'install 'install-doc
+ (lambda* (#:key outputs #:allow-other-keys)
+ (let ((docdir (string-append (assoc-ref outputs "out")
+ "/share/doc/tomsfastmath")))
+ (install-file "doc/tfm.pdf" docdir)
+ #t)))
+ (add-after 'install 'install-pc
+ (lambda* (#:key outputs #:allow-other-keys)
+ (let* ((out (assoc-ref outputs "out"))
+ (pc-dir (string-append out "/lib/pkgconfig")))
+ (call-with-output-file "tomsfastmath.pc"
+ (lambda (port)
+ (format port "~
+Name: TomsFastMath
+Description: ~a
+Version: ~a
+Libs: -L~a/lib -ltfm~%"
+ ,synopsis ,version out)))
+ (install-file "tomsfastmath.pc" pc-dir)
+ #t))))))
+ (home-page "http://www.libtom.org/TomsFastMath/")
+ (description "TomsFastMath is a large integer library written in portable
+ISO C. It is a port of LibTomMath with optional support for inline assembler
+multiplies.")
+ (license public-domain)))
diff --git a/gnu/packages/patches/tomsfastmath-constness.patch b/gnu/packages/patches/tomsfastmath-constness.patch
new file mode 100644
index 0000000000..7c6ab5bbec
--- /dev/null
+++ b/gnu/packages/patches/tomsfastmath-constness.patch
@@ -0,0 +1,76 @@
+From dac089515901d6bf315cd15a6e744b8d2c02c1cb Mon Sep 17 00:00:00 2001
+From: Sebastian Andrzej Siewior <sebastian@breakpoint.cc>
+Date: Sat, 31 Oct 2015 22:48:07 +0100
+Subject: [PATCH] tfm: make a few functions static
+
+clamav expects them to be static and it does not seem bad to do so.
+
+Signed-off-by: Sebastian Andrzej Siewior <sebastian@breakpoint.cc>
+---
+ src/bin/fp_read_radix.c | 2 +-
+ src/bin/fp_read_signed_bin.c | 2 +-
+ src/bin/fp_read_unsigned_bin.c | 2 +-
+ src/headers/tfm.h | 6 +++---
+ 4 files changed, 6 insertions(+), 6 deletions(-)
+
+diff --git a/src/bin/fp_read_radix.c b/src/bin/fp_read_radix.c
+index 0b5e826..431afa0 100644
+--- a/src/bin/fp_read_radix.c
++++ b/src/bin/fp_read_radix.c
+@@ -9,7 +9,7 @@
+ */
+ #include <tfm_private.h>
+
+-int fp_read_radix(fp_int *a, char *str, int radix)
++int fp_read_radix(fp_int *a, const char *str, int radix)
+ {
+ int y, neg;
+ char ch;
+diff --git a/src/bin/fp_read_signed_bin.c b/src/bin/fp_read_signed_bin.c
+index e2b8003..6467d19 100644
+--- a/src/bin/fp_read_signed_bin.c
++++ b/src/bin/fp_read_signed_bin.c
+@@ -9,7 +9,7 @@
+ */
+ #include <tfm_private.h>
+
+-void fp_read_signed_bin(fp_int *a, unsigned char *b, int c)
++void fp_read_signed_bin(fp_int *a, const unsigned char *b, int c)
+ {
+ /* read magnitude */
+ fp_read_unsigned_bin (a, b + 1, c - 1);
+diff --git a/src/bin/fp_read_unsigned_bin.c b/src/bin/fp_read_unsigned_bin.c
+index 3ee64c0..2ee89cb 100644
+--- a/src/bin/fp_read_unsigned_bin.c
++++ b/src/bin/fp_read_unsigned_bin.c
+@@ -9,7 +9,7 @@
+ */
+ #include <tfm_private.h>
+
+-void fp_read_unsigned_bin(fp_int *a, unsigned char *b, int c)
++void fp_read_unsigned_bin(fp_int *a, const unsigned char *b, int c)
+ {
+ /* zero the int */
+ fp_zero (a);
+diff --git a/src/headers/tfm.h b/src/headers/tfm.h
+index af87b56..f406388 100644
+--- a/src/headers/tfm.h
++++ b/src/headers/tfm.h
+@@ -467,14 +467,14 @@ int fp_prime_random_ex(fp_int *a, int t, int size, int flags, tfm_prime_callback
+ int fp_count_bits(fp_int *a);
+
+ int fp_unsigned_bin_size(fp_int *a);
+-void fp_read_unsigned_bin(fp_int *a, unsigned char *b, int c);
++void fp_read_unsigned_bin(fp_int *a, const unsigned char *b, int c);
+ void fp_to_unsigned_bin(fp_int *a, unsigned char *b);
+
+ int fp_signed_bin_size(fp_int *a);
+-void fp_read_signed_bin(fp_int *a, unsigned char *b, int c);
++void fp_read_signed_bin(fp_int *a, const unsigned char *b, int c);
+ void fp_to_signed_bin(fp_int *a, unsigned char *b);
+
+-int fp_read_radix(fp_int *a, char *str, int radix);
++int fp_read_radix(fp_int *a, const char *str, int radix);
+
+ int fp_radix_size(fp_int *a, int radix, int *size);
+ int fp_toradix(fp_int *a, char *str, int radix);